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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

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
Solution Sage
Solution Sage

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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.