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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
lfrosales
Frequent Visitor

DAX Rolling WoW with Week Numbers (no Dates)

Hi All,

 

I am trying to do something in DAX that I can easily do with Excel (show value as difference from previous "x"). In this case, I have a column of Week Numbers with their respective Widget Counts for that week number. In Excel, I can drop into the pivot table and ask it to show me the value difference from the previous week number (regardless of whether it's a date or not). Image below:

2019-05-30 17_40_52-Book13 - Excel.png

 

I tried something to the effect of:

WoW =
VAR LastWeekCount =
SUMX(
FILTER(
'Query1',
'Query1'[WeekNum] = 'Query1'[WeekNum]-1
)
, 'Query1'[Widgets])
VAR fCount = Query1[Widgets]

RETURN fCount - LastWeekCount
 
Can someone help me convert a very easy Excel feature (show value as difference based on previous "x") to a seemingly obvious DAX statement that I can't quite figure out?
 
Thanks in advance as always!
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@lfrosales add following measure

 

WoW Widget = 
VAR __prevWeek = MAX( Table1[Week] ) - 1
VAR __thisWeekWidget = SUM( Table1[Widgets] )
VAR __prevWeekWidget = CALCULATE( SUM( Table1[Widgets] ), Table1[Week] =  __prevWeek ) 
RETURN __thisWeekWidget - __prevWeekWidget


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.

View solution in original post

2 REPLIES 2
parry2k
Super User
Super User

@lfrosales add following measure

 

WoW Widget = 
VAR __prevWeek = MAX( Table1[Week] ) - 1
VAR __thisWeekWidget = SUM( Table1[Widgets] )
VAR __prevWeekWidget = CALCULATE( SUM( Table1[Widgets] ), Table1[Week] =  __prevWeek ) 
RETURN __thisWeekWidget - __prevWeekWidget


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.

Thank you so much! I was struggling a couple hours on something that seemed super straightforward and you proved that it was! In my delirium, I accidentally tried adding it as a calculated column and wasn't having any luck, then I realized that you said as a measure! Worked like a charm! The only quirk I will try to work out is that it looks at week 1 of the year and gives it a value equal to that week's widget count. I will try to figure out a way to tell it to ignore Week 1 and continue with the rest.

See below:

2019-05-30 19_39_27-Untitled - Power BI Desktop.png

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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