Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
p-deshmukh
Regular Visitor

Analyzing events with duration | Show value for missing weeks

Hello,

 

I am having trouble to get the Yield Value repeated for a duration of work weeks. 

 

I have two tables: Yield_Fact and Date_Dim. The Yield_Fact table has a Many to One relationship with the Date_Dim table as shown.

Yeild and Date Relationship.PNG

For every Material_Dwid and for a particular duration (which is given by Effective_Begin_Date_Dwid and Effective_End_Date_Dwid) I have a Yield_Qty in percentage. I want to show this Yield_Qty value in a Matrix format in a report such that the value is repeated for all the days between the Begin_Date_Dwid and the End_Date_Dwid at the week level. Currently, I am getting a Yield value only for the Begin Dates. For example, I want to show the value of 1% for all the weeks from WW2020-01 to WW2020-23. WW2020-24 will have a value of 12.1%, which already exists as shown below. 

Week Level Yield.PNG

 

I am attaching Google Drive link to the pbix file which has a sample dataset for one Material_Dwid. (Not able to find a way to upload the pbix file directly to this message. Please copy-paste this link in the browser if the hyperlink is not working).

Link: https://drive.google.com/open?id=1GnwJbSUv3gxrOu8wSeGua2P6HV44-AqP

 

The original data set has more than 1 million records. So the solution should be compatible with such a large data set. Please help. If any additional information is needed, please let me know.

 

Thank you!

Pratik

2 ACCEPTED SOLUTIONS
sturlaws
Resident Rockstar
Resident Rockstar

Hi @p-deshmukh 

working with Start date and End date-scenarios is usually a tricky in Power BI. E.g. in the sample file you have provided, there is a relationship between Yield_fact and date_dim on [date_dwid]=[effective_begining_date_dwid]. In your matrix visual you then only get the weeks where there exists data in 'Yield fact'. If you want to show values for other weeks you would need to create a measure that ignore the relationship, but at the same time maintain the relationship, which is not possible. So to solve this you could delete the relationship between the tables, or set it to inactive, or create a duplicate date_time for this purpose and use this measure:

Qty =
CALCULATE (
    MIN ( Yield_Fact[YIELD_QTY] );
    FILTER (
        Yield_Fact;
        MIN ( Date_Dim[DATE_DWID] ) >= Yield_Fact[EFFECTIVE_BEGIN_DATE_DWID]
            && MIN ( Date_Dim[DATE_DWID] ) <= Yield_Fact[EFFECTIVE_END_DATE_DWID]
    )
)

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

 

View solution in original post

Sorry, forgot to mention that you should replace work_week_name from Date_dim with work_week_name from Date2_dim

View solution in original post

3 REPLIES 3
sturlaws
Resident Rockstar
Resident Rockstar

Hi @p-deshmukh 

working with Start date and End date-scenarios is usually a tricky in Power BI. E.g. in the sample file you have provided, there is a relationship between Yield_fact and date_dim on [date_dwid]=[effective_begining_date_dwid]. In your matrix visual you then only get the weeks where there exists data in 'Yield fact'. If you want to show values for other weeks you would need to create a measure that ignore the relationship, but at the same time maintain the relationship, which is not possible. So to solve this you could delete the relationship between the tables, or set it to inactive, or create a duplicate date_time for this purpose and use this measure:

Qty =
CALCULATE (
    MIN ( Yield_Fact[YIELD_QTY] );
    FILTER (
        Yield_Fact;
        MIN ( Date_Dim[DATE_DWID] ) >= Yield_Fact[EFFECTIVE_BEGIN_DATE_DWID]
            && MIN ( Date_Dim[DATE_DWID] ) <= Yield_Fact[EFFECTIVE_END_DATE_DWID]
    )
)

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

 

Hi @sturlaws,

Thank you for your message. 

I created a new table called Date 2_Dim, which is a copy of Date_Dim and used the Date_Dwid fields in the measure formula from the new table. And I replaced the Yield_Qty field with the new measure 'Qty' in the matrix visual, but it is not giving me the desired result. Am I doing it right? Aren't we supposed to use Cross Join in some way?

 

Please find the new pbix file with the solution suggested by you: https://drive.google.com/open?id=1qfYTOGCqfzTam7xgHRmd4reiD_snZurc

 

Please help. Thank you in advance!

Sorry, forgot to mention that you should replace work_week_name from Date_dim with work_week_name from Date2_dim

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.