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

Trended Weeks over Prior Period Help

Hello! 

 

I'm hoping someone can help me write a DAX statement for a prior period (latest 12, 26, 52 weeks) which I'd like to then turn into a % chg. I have weekly data now which i've created trended times for, but I don't know how to get the prior periods trended time.

 

Below is one of my current formula's for latest 24wks periods:

 

Latest 24 Wks = CALCULATE(sum(Kroger[Units]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-23 && 'Date'[Week Rank]<=max('Date'[Week Rank])))
 
Thanks for your help!!
1 ACCEPTED SOLUTION

This is fantastic! I think I can figure out the rest from here, thank you so much for breaking this down. 

 

View solution in original post

4 REPLIES 4
v-jianboli-msft
Community Support
Community Support

Hi @AndrewUrban ,

 

Please follow these steps:

1. Create a new table with all the options you need in the slicer.

vjianbolimsft_0-1656398094833.png

2. Turn the single select of the slicer on

vjianbolimsft_1-1656398094837.png

3. Then create a measure that calculate a prior period.

 

 

Measure =

SWITCH( MAX('for sliceer'[Value]),

"Last 12 Weeks",

CALCULATE(SUM(Kroger[Units]),FILTER(ALL('Date'),'Date'[Week Rank] >= MAX('Date'[Week Rank])-11 && 'Date'[Week Rank] <= MAX('Date'[Week Rank]))),

"Last 26 Weeks",

CALCULATE(SUM(Kroger[Units]),FILTER(ALL('Date'),'Date'[Week Rank] >= MAX('Date'[Week Rank])-25 && 'Date'[Week Rank] <= MAX('Date'[Week Rank]))),

CALCULATE(SUM(Kroger[Units]),FILTER(ALL('Date'),'Date'[Week Rank] >= MAX('Date'[Week Rank])-51 && 'Date'[Week Rank] <= MAX('Date'[Week Rank])))

)

 

4. Final output

 

vjianbolimsft_2-1656398094838.png

 

vjianbolimsft_3-1656398094839.png

 

In addition, what's the logic of "a % chg", please provide more details to help us clarify your scenario.

 

Best Regards,

Jianbo Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is fantastic! I think I can figure out the rest from here, thank you so much for breaking this down. 

 

ManguilibeKAO
Resolver I
Resolver I

Hi AndrewUrban,

 

Coud you show the tables in your data model?

 

Best regards.

Hi,

 

Thanks for the reply, see below for my "Date" table:

 

AndrewUrban_2-1656336292321.png

 

 

 

 

 

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.

Top Solution Authors