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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Tihannah
Resolver II
Resolver II

Prior Week Calculation with Segments

My Prior Week Calculation is working fine... until I bring segments in.

 

This is my dax:

Prior Wk Sales = CALCULATE(SUM(Table[Sales]),FILTER(ALL(Date Table),Date Table[WeekRank]=MAX(Date Table[WeekRank])-1))
 
In this table, I have both a Week Rank and Week Number column:
WeekRank = RANKX(ALL(Date Table),Date Table[WkStartDate],,ASC,Dense)
WeekNum = WEEKNUM('Date Table'[WkStartDate])
WkStartDate = Date Table[Business_Date] - WEEKDAY('Date Table'[Business_Date],2)+1
WkEndDate = Date Table[Business_Date] -WEEKDAY(Date Table[Business_Date],2)+7
 
I have 3 business segments I'm looking. And they have their own dimension table. I'll call them:
Books
Shoes
Candles
 
If I'm just looking at a roll up, prior week calc works fine. But when I bring in the segments, the rollup just duplicates under each segment. What am I missing?? 
 
 
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @Tihannah,

 

I've tried recreating your use case usnig my dummy data and it seems that your segment table doesn't have a relationship with your fact/sales table. You can see in the screenshot below that prior week is split into segments

 

danextian_0-1685789137527.png

Without the relationship, you'll see equal amounts for each segment by week.

danextian_1-1685789206170.png

Please see attached pbix for your reference. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

2 REPLIES 2
danextian
Super User
Super User

Hi @Tihannah,

 

I've tried recreating your use case usnig my dummy data and it seems that your segment table doesn't have a relationship with your fact/sales table. You can see in the screenshot below that prior week is split into segments

 

danextian_0-1685789137527.png

Without the relationship, you'll see equal amounts for each segment by week.

danextian_1-1685789206170.png

Please see attached pbix for your reference. 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

My segment table did have a relationship to the fact table, but the attached file helped me figure out where I was going wrong with the week columns and my dax, so thank you!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.