Forum Discussion

Paulo123's avatar
Paulo123
Frequent Visitor
4 years ago
Solved

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.
  • ValtteriN's avatar
    4 years ago

    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!



  • Paulo123's avatar
    Paulo123
    4 years ago

    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))
    RETURN
    DIVIDE(Dados[SOMA_E] - _MES_ANTERIOR,_MES_ANTERIOR))