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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.