Forum Discussion

kang990's avatar
kang990
Frequent Visitor
2 years ago

Summarize table with zero

Hello,

I have two tables as below:

 

Sales

SalespersonDateCategory
AAA2023-01-02BAT
BBB2023-03-03TGA
AAA2023-03-03TGA
BBB2023-03-03TGA
CCC2023-04-23BAT
CCC2023-04-23TGA

 

Salespersons

NameDept
AAA01
BBB01
CCC04

 

How can I use SUMMARIZE to count by Date, Category and Salesperson? As not every salesperson has category on that day. I wish to have the result like this, no matter they have sales or not on each day. If no sales, display 0.

DateSalespersonCategoryCount
2023-01-02AAABAT1
2023-01-02AAATGA0
2023-01-02BBBBAT0
2023-01-02BBBTGA0
2023-01-02CCCBAT0
2023-01-02CCCTGA0
2023-03-03AAABAT0
2023-03-03AAATGA1
2023-03-03BBBBAT0
2023-03-03BBBTGA2
2023-03-03CCCBAT0
2023-03-03CCCTGA0
2023-04-23AAABAT0
2023-04-23AAATGA0
2023-04-23BBBBAT0
2023-04-23BBBTGA0
2023-04-23CCCBAT1
2023-04-23CCCTGA1

 

With the summarize command I wrote it wouldn't include zero for everyone. How can I solve this issue?

 

Link to pbix file

 

Any help is greatly appreciated!

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi kang990 ,

     

    Has your problem been solved? If the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. Thanks in advance.

    For your follow-up questions, you can create a new post and describe your problem in detail. More users and engineers will be involved to help you.

     

    Best Regards,

    Neeko Tang

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

  • Cnt = 
    ADDCOLUMNS(
        CROSSJOIN(
            DISTINCT( Sales[Date] ),
            DISTINCT( Salespersons[Salesperson] ),
            DISTINCT( Sales[Category] )
        ),
        "Cnt", CALCULATE( COUNTROWS( Sales ) ) + 0
    )

    • kang990's avatar
      kang990
      Frequent Visitor

      A follow up question, how can I bring the Dept from Salespersons in to the summarized table?

    • kang990's avatar
      kang990
      Frequent Visitor

      Hi ThxAlot , it worked in this way. Thank you for your help! 🙂