Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
kzorina
Frequent Visitor

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?

1 ACCEPTED SOLUTION

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

5.JPG4.JPG

 

 

Best Regards,

Lin

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

View solution in original post

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

hi, @kzorina 

You could try this way as below:

Step1:

You need to define buckets table.

1.JPG

Step2:

Use this formula to create the measure

Measure = var _amount= CALCULATE(COUNTA('Table'[PurchaseId])) return
CALCULATE(MAX(buckets[Tag]),FILTER(buckets,_amount>=buckets[From]&&_amount<=buckets[To]))

Result:

2.JPG3.JPG

 

Best Regards,

Lin

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

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?

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

5.JPG4.JPG

 

 

Best Regards,

Lin

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

@v-lili6-msft Thanks a lot! That worked!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.