Search code examples
countpowerbicategories

DAX Column to count by category


I am trying to create a DAX Column that counts the occurrences in a month. Power BI built-in table function already counts them by category, but I need to create a column that saves the result in order to compare it to other values.

In the picture below you can see the 3 columns: The "Count" column is what I am trying to compute and it should return the same result as the "ID" column, but you can see that it only returns the total number of entries and not by categories.

Any idea how I could compute it? Thank you in advance!

Best regards, Denis

enter image description here


Solution

  • It's not clear what you mean by category, but I think this should get you in the ballpark:

    Count = CALCULATE(SUM('Table'[ID ]),
        FILTER('Table',EARLIER('Table'[Month])='Table'[Month]))
    

    Maybe you need a COUNT instead of a SUM, or a different column, but the FILTER(...,EARLIER()) is the important part.