Forum Discussion

kzorina's avatar
kzorina
Frequent Visitor
7 years ago
Solved

Measure based on grouped calculation without summarize

I need to calculate measure based on groups. And tricky part is that I cannot use summarize as I need to have date filter and measure should dynamically change when I change a filter.

For example for data:

dayPurchaseIdUserId
111
121
132
142
153
261
272
283
294
3101
3114
3124
3134
3144
4151
4162
4173

 

When filter is all days - i want to see

UserIdAmount of purchases
15
24
33
45

 

And when filter is 3-4 day

UserIdAmount of purchases
12
21
31
44

 

EDITED

Moreover I want to have buckets afterwards, based on this amount (for exmple, 1-2 purchases, 3-5 purcahes) and operate with them

BucketAmount of users
1-2 purchases 0
3-5 purcahes 4

filter 3-4 day

BucketAmount of users
1-2 purchases 3
3-5 purcahes 1

 

Any ideas, how can I do this?

  • hi, kzorina 

    You could use this formula to add a new measure

    Measure 2 = var _table=SUMMARIZE(GENERATE(buckets,'Table'), [Tag],[From],[To],[UserId],"Amount of users",CALCULATE(COUNTA('Table'[PurchaseId]))) return
    COUNTAX(FILTER(_table,[Amount of users]>=[From]&&[Amount of users]<=[To]),[UserId])

    Then drag Tag field from buckets table and the measure into a visual

     

     

    Best Regards,

    Lin

4 Replies

    • kzorina's avatar
      kzorina
      Frequent Visitor

      Thanks, v-lili6-msft for a quick answer

       

      Can I somehow achive it in a way so I can operate with bucket as fixed value. for example, calculate amount of users in some bucket?

      • v-lili6-msft's avatar
        v-lili6-msft
        Community Support

        hi, kzorina 

        You could use this formula to add a new measure

        Measure 2 = var _table=SUMMARIZE(GENERATE(buckets,'Table'), [Tag],[From],[To],[UserId],"Amount of users",CALCULATE(COUNTA('Table'[PurchaseId]))) return
        COUNTAX(FILTER(_table,[Amount of users]>=[From]&&[Amount of users]<=[To]),[UserId])

        Then drag Tag field from buckets table and the measure into a visual

         

         

        Best Regards,

        Lin