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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DAX that works with/rolls up to different dimensions

Hello All,

 

I have had a look for this topic and can't find any discussion about it so i'm either the first to ask or my search paremeters are shocking.

 

Either way, I need some help! I have a requirement to compare a sum total to the same day in the previous week to provide a week on week variance. This is an amendment to an existing report in my business that was originaly aggregating numbers per week. Now the requirements is to look at these figures each day of the week but it still needs to be aggreagated for the week. This is where i am struggling as I can either get it to work for each day or for the week as a total. I've tried simply using DATEADD but this always results in an error (returns multiple results when it expects one). 

My source data is an aggregated view that appears as follows:

ChrisGRobinson_0-1637171406913.png

 

This is linked with a DIM_DATE table with many columns but the ones used in my report are the Calendar_Date (for the relationship to the KPIs table shown above), [Start of Week], [FISCAL_WEEK], [WEEK_DAY_NAME]. 

 

The normal SUM DAX for the Gross Orders per day is fine (as you'd expect), but my WOW% comparison is being a pain:

ChrisGRobinson_1-1637171739099.png

 

My current DAX is as follows:

 

Orders WOW Growth =
VAR SumOrders =
SUMX ( SALES_KPIS, SALES_KPIS[GrossOrders] )
VAR PreviousFiscalWeek =
MAX ( DIM_DATE[FISCAL_WEEK] ) - 1
VAR WeekDayName =
SELECTEDVALUE ( DIM_DATE[WEEK_DAY_NAME] )
VAR OrdersPreviousWeekDay =
CALCULATE (
SUM ( SALES_KPIS[GrossOrders] ),
FILTER ( ALL ( DIM_DATE ), DIM_DATE[FISCAL_WEEK] = PreviousFiscalWeek ),
DIM_DATE[WEEK_DAY_NAME] = WeekDayName
)
VAR OrdersPreviousWeek =
CALCULATE (
SUM ( SALES_KPIS[GrossOrders] ),
FILTER ( ALL ( DIM_DATE ), DIM_DATE[FISCAL_WEEK] = PreviousFiscalWeek )
)
VAR GrowthPercentage =
IFERROR (
( SumOrders - OrdersPreviousWeekDay ) / OrdersPreviousWeekDay,
BLANK ()
)
RETURN
GrowthPercentage
 
If i swap out the variable 'OrdersPerviousWeekDay' with 'OrdersPreviousWeek', i do get the figure for the week but it also gives me the weekly total for each day which is not what i need! Is there anybody on here that can help point me in the right direction. I've tried using a combination of SWITCH and IF commands as well but return errors each time! I've been trying to get this to work for a day and its now time to raise the white flag. Any help will be appreciated!
 
Thanks,
 
Chris 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Update - i retried DATEDIFF this morning and it suddenly works the way I need it to. Very odd, i must have used an incorrect column in my original version of the DATEDIFF formula and not realised. 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Update - i retried DATEDIFF this morning and it suddenly works the way I need it to. Very odd, i must have used an incorrect column in my original version of the DATEDIFF formula and not realised. 

Anonymous
Not applicable

Orders WOW Growth =
VAR SumOrders = SUM ( SALES_KPIS[GrossOrders] )
VAR SumLastWeek = CALCULATE(SUM(SALES_KPIS[GrossOrders]),DATEADD(DIM_DATE[CALENDAR_DATE],-7,DAY))
RETURN
(SumLastWeek-SumOrders)/SumLastWeek

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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