cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper III

## Calculated percentage value for columns

Hello,

I have simplified the problem here where I want to represent this "Calculated Value" in a visual against the many different "Subjects". I don't want to calculate it in Excel but rather do it automatically in Power BI so as to keep the dashboard interactive.

 Student Subject  A Subject  B Subject  X Student 1 4 1 . Student 2 2 3 . Student 3 1 4 . Student 4 3 3 . Student 5 4 2 . Student 6 0 3 .

The formula I'm using is calculating the percentage of occurrences of values 4 and 3 out of values 4, 3, and 2.

=(COUNTIF(B2:B7,4) + COUNTIF(B2:B7,3)) * 100 / (COUNTIF(B2:B7,4) + COUNTIF(B2:B7,3) + COUNTIF(B2:B7,2))

I have unpivoted the columns to represent the skills.

Please suggest how to calculate those values to make another visual that interacts with my existing one.

1 ACCEPTED SOLUTION
Community Champion

@TinyElephant Yes, you can pivot the data to have one column for  subject

create a measure like below

Measure_SubA = CALCULATE(COUNT(tab_stud[Subject]),tab_stud[Skill_Level]=4 || tab_stud[Skill_Level]=3)/
CALCULATE(COUNT(tab_stud[Subject]),tab_stud[Skill_Level]=4 || tab_stud[Skill_Level]=3|| tab_stud[Skill_Level]=2)

pbix attached as well.

FYI. if there is something which can be done easily in excel and data size is not too big then it would be advisable to use excel instead of powerbi. PowerBI can be used in situation where data is coming from different sources and some linking needs to be done. Also, cross filtering is one of the key feature of powerbi which can make easy to understand big data.

Proud to be a Super User!

3 REPLIES 3
Community Champion

@TinyElephant  you can create a measure like below

Measure_SubA = CALCULATE(COUNT(tab_stud[Subject  A]),tab_stud[Subject  A]=4 || tab_stud[Subject  A]=3) /
CALCULATE(COUNT(tab_stud[Subject  A]),tab_stud[Subject  A]=4 || tab_stud[Subject  A]=3|| tab_stud[Subject  A]=2)

Proud to be a Super User!

Helper III

The Student Data table is unpivoted now as seen in the image above. Do you want me to duplicate the original table to preserve Subject columns?
So, do I need to create this measure for each and every subject there is? Excel seems faster here as it already can have the calculated value using a formula. Is there any other benefit of dashboard interaction?

Community Champion

@TinyElephant Yes, you can pivot the data to have one column for  subject

create a measure like below

Measure_SubA = CALCULATE(COUNT(tab_stud[Subject]),tab_stud[Skill_Level]=4 || tab_stud[Skill_Level]=3)/
CALCULATE(COUNT(tab_stud[Subject]),tab_stud[Skill_Level]=4 || tab_stud[Skill_Level]=3|| tab_stud[Skill_Level]=2)

pbix attached as well.

FYI. if there is something which can be done easily in excel and data size is not too big then it would be advisable to use excel instead of powerbi. PowerBI can be used in situation where data is coming from different sources and some linking needs to be done. Also, cross filtering is one of the key feature of powerbi which can make easy to understand big data.

Proud to be a Super User!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors