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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
j_gan2022
Frequent Visitor

Summarize Table as Measure

Hi I have a dataset as below

 

My objective is to create a histogram to calculate the number of students vs number of attendances as below. This histogram has to be dynamic to slicer date range

 

j_gan2022_0-1644387993348.png

 

 

 

Student IDAttendance Date
120/Jan/2022
220/Jan/2022
120/Jan/2022
221/Jan/2022
221/Jan/2022
321/Jan/2022
321/Jan/2022
422/Jan/2022
322/Jan/2022
422/Jan/2022

 

My main idea is to create a group for my X axis

 

GroupMin ValueMax Value
0 - 10010
10 - 201020
20 - 302030
30 - 403040
40 - 504050
50 - 605060
60 - 706070
70 - 807080
80 - 908090

 

Then link the Group and a dynamic Summarize Table.

However I cant insert ["Total Attendance"] in the Summarize Column into XX. Please advise

 

 

Measure = 
VAR Table = SUMMARIZE(Data, Data[Student ID], "Total Attendance", COUNTROWS(Data) ) 
VAR Result = COUNTROWS( FILTER(MasterGroup, MasterGroup[Min Value] < XX && MasterGroup[Max Value] >= XX ) ) 
RETURN Result

 

 

 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

@j_gan2022 , Sorry Some mistake

Option one is a new table

 

If you need measure

 

meausre =
VAR _table = SUMMARIZE(Data, Data[Student ID], "Total Attendance", COUNTROWS(Data) )
var _count = countx(filter(_table, [Total Attendance] >=Min(MasterGroup[Min Value] ) && [Total Attendance] <=max(MasterGroup[Max Value] )),[Student ID])
return
_count

 

 

------

If you need table

 

 

Table = 
VAR Table = SUMMARIZE(Data, Data[Student ID], "Total Attendance", COUNTROWS(Data) ) 
return 
Addcolumns(Table , "Bucket"
[Total Attendance]	<= 10, "  0 -10" ,
[Total Attendance]	<= 20, " 10 -20" ,
[Total Attendance]	<= 30, " 20 -30" ,
[Total Attendance]	<= 40, " 40 -40" ,
//Add other 
)

 

 

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
j_gan2022
Frequent Visitor

Thanks the Measure works.!

amitchandak
Super User
Super User

@j_gan2022 , You should use add columns and add between range

 

Var Result = Addcolumns(Table , "Bucket"
[Table] <= 10, " 0 -10" ,
[Table] <= 20, " 10 -20" ,
[Table] <= 30, " 20 -30" ,
[Table] <= 40, " 40 -40" ,
//Add other
)

 

or explore this , place of margin you have total student

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  sorry i dont understand how this works.

 

Var Result = Addcolumns(Table , "Bucket"
[Table] <= 10, " 0 -10" ,
[Table] <= 20, " 10 -20" ,
[Table] <= 30, " 20 -30" ,
[Table] <= 40, " 40 -40" ,
//Add other
)

 

How do i link it to my group? Please advise. Thanks. I need it to be able to change according to slicer.

@j_gan2022 , Sorry Some mistake

Option one is a new table

 

If you need measure

 

meausre =
VAR _table = SUMMARIZE(Data, Data[Student ID], "Total Attendance", COUNTROWS(Data) )
var _count = countx(filter(_table, [Total Attendance] >=Min(MasterGroup[Min Value] ) && [Total Attendance] <=max(MasterGroup[Max Value] )),[Student ID])
return
_count

 

 

------

If you need table

 

 

Table = 
VAR Table = SUMMARIZE(Data, Data[Student ID], "Total Attendance", COUNTROWS(Data) ) 
return 
Addcolumns(Table , "Bucket"
[Total Attendance]	<= 10, "  0 -10" ,
[Total Attendance]	<= 20, " 10 -20" ,
[Total Attendance]	<= 30, " 20 -30" ,
[Total Attendance]	<= 40, " 40 -40" ,
//Add other 
)

 

 

 

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.