cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
talderton
Frequent Visitor

Horizontal bar charts

Hi everyone,

 

I have created the table shown below that shows the % of positive answers by students for each school.

I have used the following calculation in my table:

 

Positive response percentage of students = DIVIDE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLSELECTED(('MACSIS 2019 and 2021 survey restructured'[Positive_response]))))

 

(The variable 'positive response' is a simple binomal variable with the categories 'positive' and 'negative''

 

I now want to do the following:

 

Create a horizontal bar chart from the tabular data showing schools down the side rank ordered by the % positive. I also want to remove the 'positive response' column. Please see what I mean from the viz created in Tableau.

 

Any ideas how I do this in Power BI?

 

Thank you!

 

Capture.PNGCapture2.PNG

13 REPLIES 13
talderton
Frequent Visitor

Thanks.

It didnt like this formula.

So I changed it slightly to get the correct variable names.

Now it still doenst like one aspect of it (shown in red below):

DIVIDE (CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLEXCEPT('MACSIS 2019 and 2021 survey restructured','MACSIS 2019 and 2021 survey restructured'[Enumber]),('MACSIS 2019 and 2021 survey restructured'[Positive response]=("Positive"), CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLEXCEPT('MACSIS 2019 and 2021 survey restructured','MACSIS 2019 and 2021 survey restructured'[Enumber]),('MACSIS 2019 and 2021 survey restructured'[Positive reponse]] in {"Positive","Negative"}))))))
 
Can you advise?
 
Thanks

Hi @talderton 

Whether you mean to show the ratio of negative types and positive types, if you need to calculate this, you can consider the following two methods

1.Put the [Positive response] into a slicer, then create the measure

 

 

Positive response percentage of students = DIVIDE (CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLEXCEPT('MACSIS 2019 and 2021 survey restructured','MACSIS 2019 and 2021 survey restructured'[Enumber]),'MACSIS 2019 and 2021 survey restructured'[Positive reponse]] in {"Positive","Negative"}))

 

 

2.You need to create two measures, one is positive, the other is negative. the measure can refer to the original measure I offered before. The originsl measure calculates positive type, then you need to create a new measure to calculate negative type.

 

Best Regards!

Yolo Zhu

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

 

Thanks for that.

 

I am getting a message that: 'The end of the input was reached' for this calculation, but nothing is showing in red so its not telling me why its failed.

Hi @talderton 

Can you provide some error message picture?

 

Best Regards!

Yolo Zhu

 

Sure, please see belowCapture.PNG

Hi @talderton 

Based on the message on the picture, please remove the additional "]"

vxinruzhumsft_0-1679021047003.png

 

Best Regards!

Yolo Zhu

Thanks.

I am now getting this error message:

Capture.PNG

Hi @talderton 

Please try the following code again

Positive response percentage of students = DIVIDE (CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students])),CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLEXCEPT('MACSIS 2019 and 2021 survey restructured','MACSIS 2019 and 2021 survey restructured'[Enumber]),'MACSIS 2019 and 2021 survey restructured'[Positive reponse]] in {"Positive","Negative"}))

Best Regards!

Yolo Zhu

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

 

 

No, sorry.

Just back to the e'nd of the input was reached' error message again.

Hi @talderton 

I made some change on it please try the following code

Positive response percentage of students = DIVIDE (CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students])),CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLEXCEPT('MACSIS 2019 and 2021 survey restructured','MACSIS 2019 and 2021 survey restructured'[Enumber]),'MACSIS 2019 and 2021 survey restructured'[Positive reponse] in {"Positive","Negative"}))

Best Regards!

Yolo Zhu

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

THanks very much. That now works to create the variable.

But how do I now use that to create the visualisation in my first post? i.e. with schools on the Y axis, the survey year on the X axis showing this calculated as the measure with the change between the two latest years shown in the final column?. Like this:

 

Capture.PNG

Hi @talderton 

You can use the following visual

vxinruzhumsft_0-1679026329712.png

 

 

But it cannot display the change , the default visuals power bi have offered cannot do this

 

Best Regards!

Yolo Zhu

v-xinruzhu-msft
Community Support
Community Support

Hi @talderton 

You can refer to the following measure

Positive response percentage of students = DIVIDE (CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLEXCEPT('MACSIS 2019 and 2021 survey restructured','MACSIS 2019 and 2021 survey restructured'[Enumber]),[Positive_response]="Positive"),CALCULATE (sum('MACSIS 2019 and 2021 survey restructured'[Number of students]),ALLEXCEPT('MACSIS 2019 and 2021 survey restructured','MACSIS 2019 and 2021 survey restructured'[Enumber]),[Positive_response] in {"Positive","Negative"}))

 

Then put the measure to the visual and set sort by Measure

vxinruzhumsft_0-1678416876033.png

Best Regards!

Yolo Zhu

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

 

 

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors