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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
qwertzuiop
Advocate III
Advocate III

Create Data Structure for Histogram

Hello dear Power BI Community

 

Following problem to solve:

Lets assume this table:

 

Check_IDPersonRating
1Agood
2Abad
3Abad
4Bbad
5Bgood
6Cbad
7Cgood
8Cbad
9Cbad
10Dbad
11Dgood
12Egood
13Ebad
14Egood

 

I would like to graphically show a distribution of the number of people in relation to the number of "Bad" ratings given.

In summary, the following data structure would have to be read out for this purpose

 

GOAL:

Num_of_Rating_BadNum_of_Persons
13
21
31


1x "Bad" rating was given by three people (B,D,E)

2x "Bad" rating was given by one people (A)

3x "Bad" rating was given by one people (C)

Finally, I would like to create a histogram from it.

In this case it would look like this whre x-axis is the num of persons any y-axis the num of bad ratings given.
Task.JPG

 

Thank you very much for your contribution.

 

Cheers

qwertzuiop

 

1 ACCEPTED SOLUTION

In this case, you'll need to modify the solution like that:

Table = 
VAR tbl = SUMMARIZE ( data, data[Person], "Num_of_Rating_Bad", COUNTX ( CALCULATETABLE ( data, data[Rating] = "bad", data[Survey] = "ABC" ), data[Rating] ) )
RETURN SUMMARIZE ( tbl, [Num_of_Rating_Bad], 
                   "Num_of_Persons", 
                   VAR CurrentValue = [Num_of_Rating_Bad]
                   RETURN COUNTX ( FILTER ( tbl, [Num_of_Rating_Bad] = CurrentValue ), [Person] ) )

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

View solution in original post

3 REPLIES 3
barritown
Super User
Super User

Hi @qwertzuiop,

 

Try creating a new table using the query below.

 

barritown_0-1683709609418.png

 

And in text format for convenience:

Table = 
VAR tbl = SUMMARIZE ( data, data[Person], "Num_of_Rating_Bad", COUNTX ( FILTER ( data, data[Rating] = "bad"), data[Rating] ))
RETURN SUMMARIZE ( tbl, [Num_of_Rating_Bad], 
                   "Num_of_Persons", 
                   VAR CurrentValue = [Num_of_Rating_Bad]
                   RETURN COUNTX ( FILTER ( tbl, [Num_of_Rating_Bad] = CurrentValue ), [Person] ) )

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Hello @barritown 

 

Thank you very much for your help.Works so far perfect ‌‌

But let me add another complexity.

Excuse me, i did not think of having to consider this as well


What if the ratings come from two surveys (Survey ABC / Survey DEF)

 

Check_IDPersonRatingSurvey
1AgoodDEF
2AbadABC
3Abad...
4Bbad 
5Bgood 
6Cbad 
7Cgood 
8Cbad 
9Cbad 
10Dbad 
11Dgood 
12Egood 
13Ebad 
14Egood 

How do I have to adjust the code you gave me to consider just "Survey ABC" for example?

 

This would be so big, if you could sovle this as well.

Cheers

qwerzuiop

In this case, you'll need to modify the solution like that:

Table = 
VAR tbl = SUMMARIZE ( data, data[Person], "Num_of_Rating_Bad", COUNTX ( CALCULATETABLE ( data, data[Rating] = "bad", data[Survey] = "ABC" ), data[Rating] ) )
RETURN SUMMARIZE ( tbl, [Num_of_Rating_Bad], 
                   "Num_of_Persons", 
                   VAR CurrentValue = [Num_of_Rating_Bad]
                   RETURN COUNTX ( FILTER ( tbl, [Num_of_Rating_Bad] = CurrentValue ), [Person] ) )

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.