Forum Discussion
Paulo123
4 years agoFrequent Visitor
variation
I wanted to calculate the monthly change from the current month to the previous month. but I want it to display the results only when I select the month filter.
Hi,
You can use ISFILTERED or HASONEFILTER to check if a slicer is applied and then use this in IF condition.
e.g.
DAX:LM IF FILTERED = IF(HASONEFILTER('Calendar'[Today].[Month]),CALCULATE('Matrix example'[Measure 6],DATEADD('Calendar'[Date],-1,MONTH)),BLANK())End result (with and without filter):I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
I adapted the answer to my need
VAR MES% = if(HASONEFILTER(CALENDARIO[Date].[Mês]),VAR _MES_ANTERIOR=CALCULATE(Dados[SOMA_E],DATEADD(CALENDARIO[Date],-1,MONTH))RETURNDIVIDE(Dados[SOMA_E] - _MES_ANTERIOR,_MES_ANTERIOR))
2 Replies
- ValtteriNCommunity Champion
Hi,
You can use ISFILTERED or HASONEFILTER to check if a slicer is applied and then use this in IF condition.
e.g.
DAX:LM IF FILTERED = IF(HASONEFILTER('Calendar'[Today].[Month]),CALCULATE('Matrix example'[Measure 6],DATEADD('Calendar'[Date],-1,MONTH)),BLANK())End result (with and without filter):I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
- Paulo123Frequent Visitor
I adapted the answer to my need
VAR MES% = if(HASONEFILTER(CALENDARIO[Date].[Mês]),VAR _MES_ANTERIOR=CALCULATE(Dados[SOMA_E],DATEADD(CALENDARIO[Date],-1,MONTH))RETURNDIVIDE(Dados[SOMA_E] - _MES_ANTERIOR,_MES_ANTERIOR))