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
Niiru1
Helper V
Helper V

SUMMARIZE TABLE TOP 10 with time ranges

I have a large table for 50 school students attendance per hour

 

School NameHours RangeDateValue
School 109.00 - 10.0014/09/202123
School 110.00 - 11.0014/09/202111
School 111.00 - 12.0014/09/202116
School 109.00 - 10.0015/09/202120
School 110.00 - 11.0015/09/202110
School 209.00 - 10.0014/09/20217
School 210.00 - 11.0014/09/20213
School 211.00 - 12.0014/09/202111
School 209.00 - 10.0015/09/20216

 

My aim is to PARTITION / get the TOP 10 schools by SUM into a SUMMARIZED table with all hour ranges or the ability to create a table I can create relationship to

 

Top 10 SchoolHour RangesDatesSummed Values
School 47  150
School 23  140
School 12  130
School 26  120
School 6  110
School 38  100
School 1  80
School 2  27

 

 

I have been able to get a SUMMARIZED table of the top 10 summed values with this DAX but I'm having trouble getting all the hour ranges and all the dates.

 

Measure 'DescendingTable' = 

VAR A = SUMMARIZE('Table','Table'[School Name],
"TotalAttendance",SUM('Table'[Value]),"Values",[SUM of values])

VAR B = TOPN(10,A,[TotalAttendance],DESC)
VAR C = ADDCOLUMNS(B,"Rank",RANKX(b,[TotalAttendance],,DESC,Dense))
//VAR D = ADDCOLUMNS(C,"Hours",VALUES('Table'[Hours Range]))

RETURN
c

 

 

Thanks in advance

 

2 REPLIES 2
v-angzheng-msft
Community Support
Community Support

Hi, @Niiru1 

 

Yes, you can't get it by that measure. Please check your measure. In variable A, you have summarized the school name, but you have not summarized the hour range and date. Variable A returns a unique table containing all schools. In variable D, you want to return all hour ranges and dates. The number of rows in the calculation table (10 rows?) obtained by the previous variable determines that the returned table cannot contain all hour ranges and dates.
So if you want to return the hour range and date, then you need to modify the variable A, and you need to decide which hour and which date you want to return, because a school has different time ranges and dates.

 

Hope this helps.

 

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

PaulDBrown
Community Champion
Community Champion

Can you post a depiction of the expected output including the "all hour ranges" please? If you can add more schools to the sample table (there are only two) it would also help (as opposed to having to type them ourselves without knowing the nature of the data)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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.