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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Tybaal
Helper II
Helper II

Calculate a simple percentage

Hello all, 

 

I'm starting with Power BI and DAX and I try to compute a simple percentage but I have some weird result...
I have a table and I like to see it like: 

ProductPricePrice Paid

% paid

1105

50%

2205

25%

34030

75%

 

I tried in Power BI but I see a weird result with a column percentage always at the same % and completely wrong...

 

Here is my formula but I think it's wrong also 🙂 :

 

% Paid = SUM ( 'Table'[Price Paid] ) / SUM ( 'Table'[Price] )

 

 

Can someone help me?

 

Thank you in advance.

2 ACCEPTED SOLUTIONS
PhilipTreacy
Super User
Super User

Hi @Tybaal 

Download sample PBIX with solution

SELECTEDVALUE gets the value on each row, try this

 

% Paid = SELECTEDVALUE( 'Table'[Price Paid] ) / SELECTEDVALUE ( 'Table'[Price] )

 

 

Or to avoid divide by zero problems, this will also work

% Paid = DIVIDE( SELECTEDVALUE( 'Table'[Price Paid] ) , SELECTEDVALUE ( 'Table'[Price] ) )

 

perc.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

v-shex-msft
Community Support
Community Support

HI @Tybaal,

If you are work with measure expression, aggregate functions can be used to extract the current value.
But when you work with calculated columns, if you not add any filter on these aggregate expressions they will summary whole column values instead of calculating on the current field value.

I'd like to suggest you create calculated columns without aggregate function or create measure formulas that similar to 'PhilipTreacy' shared.

 

% Paid = 'Table'[Price Paid] / 'Table'[Price]

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

HI @Tybaal,

If you are work with measure expression, aggregate functions can be used to extract the current value.
But when you work with calculated columns, if you not add any filter on these aggregate expressions they will summary whole column values instead of calculating on the current field value.

I'd like to suggest you create calculated columns without aggregate function or create measure formulas that similar to 'PhilipTreacy' shared.

 

% Paid = 'Table'[Price Paid] / 'Table'[Price]

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
PhilipTreacy
Super User
Super User

Hi @Tybaal 

Download sample PBIX with solution

SELECTEDVALUE gets the value on each row, try this

 

% Paid = SELECTEDVALUE( 'Table'[Price Paid] ) / SELECTEDVALUE ( 'Table'[Price] )

 

 

Or to avoid divide by zero problems, this will also work

% Paid = DIVIDE( SELECTEDVALUE( 'Table'[Price Paid] ) , SELECTEDVALUE ( 'Table'[Price] ) )

 

perc.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
Europe Fabric Conference

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 Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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