Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Help with a measure and filter context

Hi,

I would like some help with a measure for the stacked column chart(on the photo).

This is the case: Measure 1 is working fine, it calculates the sales for last x days according the selection in the date filter (date table).

But Measure 2 is not working correctly, it should calculate the total sales for that whole month but previous year. (not lookin at the last x days).

 

Can you please help.

Thank you.

 

 

  • Hi Anonymous ,

     

    Please try the following formula:

     

    Measure2 = 
    CALCULATE (
        SUM ( 'Table'[Value] ),
        DATEADD ( PREVIOUSMONTH ( Dates[Date] ), -11, MONTH )
    )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

4 Replies

  • netanel's avatar
    netanel
    Icon for Post Prodigy rankPost Prodigy

    Hey Anonymous 

     

    we need mor info about your case

    how your Measure looklike?

    In the meantime from my understand look at this logic it is supposed to solve the problem

    Measure 2 = CALCULATE([Your Total sales],DATEADD('Date'[Date],-1,Year))
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the reply,

      Well, for Same period last year that is the logic, but as i meantioned I want to exclude the date filter last x days. So using only this DAX is not working:

      Measure 2 = CALCULATE([Your Total sales],DATEADD('Date'[Date],-1,Year)) , it doesnt solve the problem.

      MyMeasure 1 is more complex beacuse it  takes orders created last x days(slicer) according to the filter and displays values for the sales for each month. 

      • netanel's avatar
        netanel
        Icon for Post Prodigy rankPost Prodigy

        Anonymous 

        If I do not see your formula
        It's hard for me to know how to put things together
        I would love for picture or the Measure itself

         

        If I understand you correctly then

        try to put that after the CALCUKATE

        KEEPFILTERS( 'Date'[Date] < TODAY() ),
         
        and Replace Today in the date that you need to filter
         
         

         

  • v-kkf-msft's avatar
    v-kkf-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Please try the following formula:

     

    Measure2 = 
    CALCULATE (
        SUM ( 'Table'[Value] ),
        DATEADD ( PREVIOUSMONTH ( Dates[Date] ), -11, MONTH )
    )

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.