Forum Discussion
Anonymous
7 years agoNot applicable
Nested if error in dax formula
Hi experts I have the following VAR was formula which does not work with certain visuals. I have a year slicer and a month slicer when I select year then month the result should be 112 months ba...
- 7 years ago
Hi Anonymous,
Add the following measure yo your model:
Datefilter12Month = VAR MonthsToLookBack = 12 VAR DataTableDate = MAX ( 'DimDate'[Date] ) RETURN CALCULATE ( SUM ( Sales[Sales] ); DATESINPERIOD ( dimDate[Date]; DataTableDate; - MonthsToLookBack; MONTH ) )See attach a PBIX file I prepared with a similar setup than yours.
Regards.
MFelix
MFelix
7 years agoSuper User
Hi Anonymous,
Got the file.
One confirmation you want to calculate the sum of sales 12 months back from the selected date correct?
Regards,
MFelix
Anonymous
7 years agoNot applicable
Yes...on two filters year and month
- MFelix7 years agoSuper User
Hi Anonymous,
Add the following measure yo your model:
Datefilter12Month = VAR MonthsToLookBack = 12 VAR DataTableDate = MAX ( 'DimDate'[Date] ) RETURN CALCULATE ( SUM ( Sales[Sales] ); DATESINPERIOD ( dimDate[Date]; DataTableDate; - MonthsToLookBack; MONTH ) )See attach a PBIX file I prepared with a similar setup than yours.
Regards.
MFelix
- Anonymous7 years agoNot applicable
Many thanks sir... let me test
- Anonymous7 years agoNot applicable
MFelix..
Just looked at the file...works. but if i change the card to a visual i bar chart clustered column. i want to be able to show 12 periods.. is this possible...
- Anonymous7 years agoNot applicable
Hi
Not sure do you want me to close question and re post. or is this still open?