Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
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:
Product | Price | Price Paid | % paid |
1 | 10 | 5 | 50% |
2 | 20 | 5 | 25% |
3 | 40 | 30 | 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.
Solved! Go to Solution.
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] ) )
Regards
Phil
Proud to be a Super User!
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
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
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] ) )
Regards
Phil
Proud to be a Super User!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.
User | Count |
---|---|
98 | |
89 | |
88 | |
70 | |
69 |
User | Count |
---|---|
227 | |
127 | |
118 | |
82 | |
80 |