Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Calculate PreviousMonth doesnt work

Hi Guys,

 

I tried to calculate the total purchase id from table PurchTable from the previous month.

My current measure is:

 

Previous Month Purchase ID = CALCULATE(COUNT(PURCHTABLE[PURCHID]), PREVIOUSMONTH('DATE'[Date])) 

 

Unfortunatly it doesnt show the result...

 

 

This is the relationship between Date table and PurchTable.

 

 

 

Any suggestion?

 

Thanks in advances.

 

Rega Sanyoto

  • DAX0110's avatar
    DAX0110
    8 years ago

    In order to show the count of previous month's purchaseIDs on each row, you have to remove the relevant filter context using ALL:

     

    Previous Month Purchase ID

    = CALCULATE(

              COUNT(PURCHTABLE[PURCHID])

             , PREVIOUSMONTH('DATE'[Date])

             , ALL(PURCHTABLE[PURCHID])

              ) 

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Does that table visual have any date context? I don't see anything obvious but maybe you've just used a filter. PREVIOUSMONTH returns the month prior to the first date in the given date context. It's not just automatically the month before today.

    • Anonymous's avatar
      Anonymous
      Not applicable

      hI Anonymous,

       

      Thanks , i didnt filter any date in a slicer. I just set a date in a slicer and now it give a total amount of the count of all purchId. which is 47.

       

      But it didnt show me how much the purchid from the previous month on each row. Look at the image below. Any suggestions how i can show the numbers on each rows ?

       

      • DAX0110's avatar
        DAX0110
        Resolver V

        In order to show the count of previous month's purchaseIDs on each row, you have to remove the relevant filter context using ALL:

         

        Previous Month Purchase ID

        = CALCULATE(

                  COUNT(PURCHTABLE[PURCHID])

                 , PREVIOUSMONTH('DATE'[Date])

                 , ALL(PURCHTABLE[PURCHID])

                  )