Forum Discussion

ankush-vem's avatar
ankush-vem
Frequent Visitor
4 years ago
Solved

Total count by category and date

Hi Team, 
I would like to know how we can return a total count based on the category and date. 
Following is a matrix table of how the result should look like.

 

Thanks

 

Category23-10-202124-10-202125-10-202126-10-2021
A2384
B4216
C7102
Total136912
  • Hi ankush-vem 

     

    Just use the following measure:

     

    Measure = COUNTROWS ( 'Table' )

     

     

    As you can see, COUNTROWS counts all of the rows in the table and allocates a Count to the respective category or date dependent upon how you want it presented:

    There is no need for anything more complex and it gives you the correct total count in each of the totals (i.e. Row total and Column total).

     

    All the best 🙂

     

    Theo

     

3 Replies

  • v-zhangti's avatar
    v-zhangti
    Icon for Community Support rankCommunity Support

    Hi,@ankush-vem

    I simulated the data and calculated it to see if it can meet your needs.

    Create a measure to calculate the quantity of each product on each date.

    Count =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Category ] = MAX ( 'Table'[Category ] )
                && 'Table'[Date] = MAX ( 'Table'[Date] )
        )
    )
    

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more.

  • TheoC's avatar
    TheoC
    Icon for Community Champion rankCommunity Champion

    Hi ankush-vem 

     

    Just use the following measure:

     

    Measure = COUNTROWS ( 'Table' )

     

     

    As you can see, COUNTROWS counts all of the rows in the table and allocates a Count to the respective category or date dependent upon how you want it presented:

    There is no need for anything more complex and it gives you the correct total count in each of the totals (i.e. Row total and Column total).

     

    All the best 🙂

     

    Theo