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
Doyou21
Frequent Visitor

Summary Table Columns W/ Date Previous Date Filter

Im trying to create a new summary table...

 

Having trouble with last 3 columns that I need to filter to the same day for the past 3 wks (7, 14, 21 Days ago).  I've tried using the the column and a measure but can't seem to get the DATEADD filter for these days to work as I get all blanks as the current values. 

 

I'll be using these columns later to calculate the Average and Standard Dev for the 3 days from the current day.  Thanks in advance for the help. 

 

Summary_Fact_EDW-Extract (NEW) =
SUMMARIZE
(
'Fact_Extract'
,'Fact_Extract'[CAL_DT]
,'Fact_Extract'[Group_RPT]
,'Fact_Extract'[Device_Type_RPT]
,'Fact_Extract'[Level]
,'Fact_Extract'[WEBSITE_TRAFFIC_SOURCE]

,"Sum_Inqs",
SUM('Fact_EDW-Extract'[Inquiries])
,"Sum_Ratio_Apps",
SUM('Fact_EDW-Extract'[Ratio Apps])
,"Sum_Inqs_1Wk_Ago",
CALCULATE([Inqs Ttl]
,DATEADD('Fact_EDW-Extract'[CAL_DT],-7,DAY))
,"Sum_Inqs_2Wk_Ago",
CALCULATE(SUM('Fact_EDW-Extract'[Inquiries])
,DATEADD('Fact_EDW-Extract'[CAL_DT],-14,DAY))
,"Sum_Inqs_3Wk_Ago",  
CALCULATE([Inqs Ttl]
,DATEADD('Fact_EDW-Extract'[CAL_DT],-21,DAY)))
 
 
 

 

 

1 ACCEPTED SOLUTION

Thanks Parry2k,

 

With your "teach a person to fish method", I went back to my Date DIM Table and Added 3 date columns to have the corresponding weeks prior I needed to refference:

 

CAL_DT - 7 Days Ago = DIM_Date[CAL_DT] - 7
CAL_DT - 7 Days Ago = DIM_Date[CAL_DT] - 14
CAL_DT - 7 Days Ago = DIM_Date[CAL_DT] - 21
 
I then added relationships (inactive) connecting the current date in my FACT table to the new date columns referenced above.
 
Lastly, I created 3 measures using the new inactive relationships created below:
 
Inquiries (-7Days) =
CALCULATE(sum('Fact_EDW-Extract'[Inquiries]),
USERELATIONSHIP('Fact_EDW-Extract'[CAL_DT],DIM_Date[CAL_DT - 7 Days Ago]))
 
Inquiries (-14Days) =
CALCULATE(sum('Fact_EDW-Extract'[Inquiries]),
USERELATIONSHIP('Fact_EDW-Extract'[CAL_DT],DIM_Date[CAL_DT - 14 Days Ago]))
 
Inquiries (-21Days) =
CALCULATE(sum('Fact_EDW-Extract'[Inquiries]),
USERELATIONSHIP('Fact_EDW-Extract'[CAL_DT],DIM_Date[CAL_DT - 21 Days Ago]))
 
It worked!
 
 

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@Doyou21 

 

I just replied to other post with similar question.

 

For any date related calculations, it is best practice to have Date dimension in your model. There are many blog posts on how to add Date dimension in your model. Once you have Date table, set relationship between you transaction table and date table and use Date from date table in your measure for these time intelligence calculations.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks Parry2k,

 

With your "teach a person to fish method", I went back to my Date DIM Table and Added 3 date columns to have the corresponding weeks prior I needed to refference:

 

CAL_DT - 7 Days Ago = DIM_Date[CAL_DT] - 7
CAL_DT - 7 Days Ago = DIM_Date[CAL_DT] - 14
CAL_DT - 7 Days Ago = DIM_Date[CAL_DT] - 21
 
I then added relationships (inactive) connecting the current date in my FACT table to the new date columns referenced above.
 
Lastly, I created 3 measures using the new inactive relationships created below:
 
Inquiries (-7Days) =
CALCULATE(sum('Fact_EDW-Extract'[Inquiries]),
USERELATIONSHIP('Fact_EDW-Extract'[CAL_DT],DIM_Date[CAL_DT - 7 Days Ago]))
 
Inquiries (-14Days) =
CALCULATE(sum('Fact_EDW-Extract'[Inquiries]),
USERELATIONSHIP('Fact_EDW-Extract'[CAL_DT],DIM_Date[CAL_DT - 14 Days Ago]))
 
Inquiries (-21Days) =
CALCULATE(sum('Fact_EDW-Extract'[Inquiries]),
USERELATIONSHIP('Fact_EDW-Extract'[CAL_DT],DIM_Date[CAL_DT - 21 Days Ago]))
 
It worked!
 
 

@Doyou21 glad to hear that you have solution in place.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.