Forum Discussion
Using SUMX with other functions
Hi Experts,
I currently have a dax function
On top this
Margin % Today = CALCULATE(SUM(dailyKPI[Margin %]),'Date'[Date] = TODAY() -1)
Create a new measure
averageX(values(dailyKPI[Warehouse]) , [Margin % Today])
Nanakwame I agree with amitchandak on how to get the average calculation. See my post here if you want to understand more why: https://excelwithallison.blogspot.com/2020/09/what-does-average-mean.html
As for ignoring weekends, you can do this easily if you have a dimDate table that has a column that flags weekends or at very least a weekday column.
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html
It looks like you have a date table, so just depends on how you create the weekday column.
Assuming a 'Date'[Weekday] column that flags weekday as 1 and weekends as 0, the new measure would look something like:
Margin % Today =
VAR _Today = TODAY()
VAR _Yesterday = MAXX( FILTER( 'Date', 'Date'[Date] < _Today && 'Date'[Weekday] = 1 ), 'Date'[Date] )
RETURN
CALCULATE(SUM(dailyKPI[Margin %]),'Date'[Date] = _Yesterday)
2 Replies
- amitchandakSuper User
On top this
Margin % Today = CALCULATE(SUM(dailyKPI[Margin %]),'Date'[Date] = TODAY() -1)
Create a new measure
averageX(values(dailyKPI[Warehouse]) , [Margin % Today])
- AllisonKennedyCommunity Champion
Nanakwame I agree with amitchandak on how to get the average calculation. See my post here if you want to understand more why: https://excelwithallison.blogspot.com/2020/09/what-does-average-mean.html
As for ignoring weekends, you can do this easily if you have a dimDate table that has a column that flags weekends or at very least a weekday column.
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html
It looks like you have a date table, so just depends on how you create the weekday column.
Assuming a 'Date'[Weekday] column that flags weekday as 1 and weekends as 0, the new measure would look something like:
Margin % Today =
VAR _Today = TODAY()
VAR _Yesterday = MAXX( FILTER( 'Date', 'Date'[Date] < _Today && 'Date'[Weekday] = 1 ), 'Date'[Date] )
RETURN
CALCULATE(SUM(dailyKPI[Margin %]),'Date'[Date] = _Yesterday)