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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
zudar
Post Patron
Post Patron

Calculating a percentage based on two measures over time

Hi all,

 

I'm struggling to wrap my head around the following.

 

My report looks like this:

 

Question4.JPG

EDIT: PBI file can be found here.

 

The source tables are the three on top: Products, Entries & Durations.

 

Now, I created two (quite complex) measures based on the data in those source tables and a separate calendar table (which is referred to by the slicer on top). Those measures are represented in the bottom graph, over time: 'Measure for Visual X' & 'Measure for Visual Y'. 

 

What I need to do now, is create a KPI that calculates a percentage of X / (X + Y), so in the example above it would be 0,6/(2+1,4 + 0,6) = 15%. 

 

As you can see, I tried two variations, but I'm unable to get to the desired 15% result:

 

This one gives 20%:

 

Percentage = DIVIDE([Measure for Visual Y],[Measure for Visual X]+[Measure for Visual Y])

 

 

And this one gives 43%:

 

Percentage (AVG) = DIVIDE(AVERAGEX(Entries,[Measure for Visual Y]),AVERAGEX(Entries,[Measure for Visual X])+AVERAGEX(Entries,[Measure for Visual Y]))

 

 

Any ideas on how to get 15%? 😵

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Please try this expression that returns 15%

 

New Measures =
VAR x =
SUMX ( 'calendar', [Measure for Visual X] )
VAR y =
SUMX ( 'calendar', [Measure for Visual Y] )
RETURN
DIVIDE ( y, x + y )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
mahoneypat
Employee
Employee

Please try this expression that returns 15%

 

New Measures =
VAR x =
SUMX ( 'calendar', [Measure for Visual X] )
VAR y =
SUMX ( 'calendar', [Measure for Visual Y] )
RETURN
DIVIDE ( y, x + y )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat 


Beautiful. Thank you! 😊

amitchandak
Super User
Super User

@zudar , this should be like

Percentage (AVG) = DIVIDE([Measure for Visual Y],A[Measure for Visual X]+Entries,[Measure for Visual Y])

@amitchandak 

 

I think something went wrong when you typed out the formula. 😶

@zudar , Just use the measure no need of nay aggregation on top of it

Percentage (AVG) = DIVIDE([Measure for Visual Y],[Measure for Visual X]+[Measure for Visual Y])

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.