Forum Discussion
Midway
1 year agoHelper I
Help Modifying this DAX Formula
I have this formula, that someone here posted it in another thread, The below DAX formula defaults sales for current month and when other visual month is selected, it shows the correct sales for the...
- 1 year ago
Hi Midway
If both cost and sales are coming from the same table, then you need to remove the filter from the month slicer and any other column that is used as a sort by or a group by column. Even safer to remove tye filter from the date table completely.
var dt = eomonth( MAXX(summarize(Fact, DimDate[Date] ), dimdate[date]), 0)returnCALCULATE(SUM(Fact[SALES]) - SUM(Fact[COST])DATESBETWEEN( DimDate[Date], EOMONTH( dt, -1) + 1, dt ),ALL ( DimDate ))but what I don't understand is the reason of not using the month directly in the formula like for exampleCALCULATE(SUM(Fact[SALES]) - SUM(Fact[COST]),- DimDate[EndOfMonth] = MAX ( DimDate[EndOfMonth] )
)
tamerj1
1 year agoCommunity Champion
Hi Midway
If both cost and sales are coming from the same table, then you need to remove the filter from the month slicer and any other column that is used as a sort by or a group by column. Even safer to remove tye filter from the date table completely.
var dt = eomonth( MAXX(summarize(Fact, DimDate[Date] ), dimdate[date]), 0)
return
CALCULATE(
SUM(Fact[SALES]) - SUM(Fact[COST])
DATESBETWEEN( DimDate[Date], EOMONTH( dt, -1) + 1, dt ),
ALL ( DimDate )
)
but what I don't understand is the reason of not using the month directly in the formula like for example
CALCULATE(
SUM(Fact[SALES]) - SUM(Fact[COST]),
- DimDate[EndOfMonth] = MAX ( DimDate[EndOfMonth] )
)