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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Urgent: How to calculate percentage across 2 columns?

Hi Coaches,

I am new to Power BI.

I have 3 columns - Model ID, Materiality, RAG status

I am able to achieve the count of model IDs that have materiality-high, and RAG status- Green

However, the ask is to get the percentage as a KPI card which I am struggling with.

Marvell_0-1697032052097.png

In the above image, count of model IDs that are green and have materiality- high is 25.

and same is shown in percentage as 68%.

This percentage KPI is stand alone, and I am not able to achieve this.

PLease help me with this.

@parry2k @amitchandak @Ritaf1983 @Ahmedx 

 

1 ACCEPTED SOLUTION
Erokor
Resolver II
Resolver II

You'll want to ensure you have the Filter context the same for both items in your KPI (which it doesn't look like there is). One way to do that is to ensure that your averages are calculated at the right grain. Judging by your Matrix visual - and understanding this as a % of the total population you'll want some DAX in a measure that is something to this effect :

KPI Measure = 
VAR _GreenAndHigh = FILTER(
                           'YourTable',
                           'YourTable'[RAG Status] = "Green" && 'YourTable'[Materiality] = "High"
                           )
VAR _GreenHighCount = COUNTROWS(_GreenAndHigh)
VAR _TotalPop = COUNTROWS('YourTable')
VAR _Result = DIVIDE(_GreenHighCount, _TotalPop)
RETURN
_Result


Side note - make sure you actually have your API filtered to the timeframe you have in the header "Apr-23", else you'll be missing context.

View solution in original post

3 REPLIES 3
newtodax
Frequent Visitor

Can you upload the pbix file?

Erokor
Resolver II
Resolver II

You'll want to ensure you have the Filter context the same for both items in your KPI (which it doesn't look like there is). One way to do that is to ensure that your averages are calculated at the right grain. Judging by your Matrix visual - and understanding this as a % of the total population you'll want some DAX in a measure that is something to this effect :

KPI Measure = 
VAR _GreenAndHigh = FILTER(
                           'YourTable',
                           'YourTable'[RAG Status] = "Green" && 'YourTable'[Materiality] = "High"
                           )
VAR _GreenHighCount = COUNTROWS(_GreenAndHigh)
VAR _TotalPop = COUNTROWS('YourTable')
VAR _Result = DIVIDE(_GreenHighCount, _TotalPop)
RETURN
_Result


Side note - make sure you actually have your API filtered to the timeframe you have in the header "Apr-23", else you'll be missing context.

Anonymous
Not applicable

@Erokor Thank you so much for the quick help. With your DAX expression, I was able to achieve the rquiremnet with some little changes here & there.

Kudos!!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.