Forum Discussion

DanielClark's avatar
DanielClark
Icon for Helper II rankHelper II
9 years ago

PREVIOUSMONTH - Sum vs. Count using ID relationships

Hi,

 

I am trying to use the previous month function to grab the Sum, Count and CountRows just to try all the options here. Previosuly I was summing aggregates of transactions. Now I have a denormalized table and am trying to count the rows of the table instead to work out the values.

 

For some reason, I am not getting anything consistenatly returned from the below:

 

I have two reports that are identical from what I can see, containing the 3 measures below:

Sum Previous = CALCULATE(SUM('Test Data'[Value]) + Sum('Test Data'[Custom]), PREVIOUSMONTH('Test Data'[Date]))

CountRows Previous = CALCULATE(COUNTROWS('Test Data') + COUNTROWS('Test Data'), PREVIOUSMONTH('Dates'[Date]))

Count Previous = CALCULATE(COUNT('Test Data'[Value]) + COUNT('Test Data'[Custom]), PREVIOUSMONTH('Dates'[Date]))

 

In Report Test the Previous Month function works with Sum. But not with Count or CountRows.

In Report Test 2 the Previous Month function works with Count and CountRows. But not with Sum.

What is going on? It seems like a bug. But I may have missed something.

 

Further to this, when working with a date table, should my date key always be converable to a date, I have been given a new date data set and the PK is now an ID rather than convertable to date in PowerBI. As seen in Contoso Sales Sample.

 

 

Regards,

4 Replies

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

    Hi DanielClark,

     

    Would you please share the .pbix file which has 'Test Data' and 'Dates' tables for our analysis?

     

    Best Regards,
    Qiuyun Yu

    • DanielClark's avatar
      DanielClark
      Icon for Helper II rankHelper II

       

      v-qiuyu-msft,

       

      What is the best way to share them as I do not seem to be able to attach files to posts.

       

      Regards,

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

        Hi DanielClark,

         

        You can upload files to OneDirve or Dropbox then share the link here.

         

        Best Regards,
        Qiuyun Yu