Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Need help with Grouping Data

 

Hello everybody! I can't GROUPBY my count of my purchases by count of my clients. 
That's user table:       
   

  

That's purchase's table:       
         

     
And that's what I want:


All this data must be filtered by date slice!

Help me please)

  • Hi Anonymous 

     

    try this approach.
    See the attached file as well

     

    First create a calculated table

     

    NewTable =
    SELECTCOLUMNS (
        GENERATESERIES ( 1, MAX ( Purchases[Count of Purchases] ) ),
        "Count of Purchases", [Value]
    )
    

    Then a Measure

     

    No. of users =
    COUNTROWS (
        FILTER (
            VALUES ( Purchases[UserId] ),
            CALCULATE ( COUNT ( Purchases[UserId] ) )
                = SELECTEDVALUE ( NewTable[Count of Purchases] )
        )
    )
    

6 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Hi Anonymous 

     

    In your Purchases Table, you can add this calculated column

    Please see attached file with your sample data

    Count of Purchases =
    CALCULATE (
        COUNT ( Purchases[UserId] ),
        ALLEXCEPT ( Purchases, Purchases[UserId] )
    )
    

    Then in Table Visual, you can drag the above calculated column and DistinctCount of UserId to get the desired result

      • Zubair_Muhammad's avatar
        Zubair_Muhammad
        Community Champion

        Hi Anonymous 

         

        try this approach.
        See the attached file as well

         

        First create a calculated table

         

        NewTable =
        SELECTCOLUMNS (
            GENERATESERIES ( 1, MAX ( Purchases[Count of Purchases] ) ),
            "Count of Purchases", [Value]
        )
        

        Then a Measure

         

        No. of users =
        COUNTROWS (
            FILTER (
                VALUES ( Purchases[UserId] ),
                CALCULATE ( COUNT ( Purchases[UserId] ) )
                    = SELECTEDVALUE ( NewTable[Count of Purchases] )
            )
        )