Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi Community,
I need help with a matrix visualization in Power BI. My dataset includes items grouped under "Crop" which contains "Area_planted" and "Crop_yield." I want to show a ratio (Area_planted / Crop_yield) for the "Crop" group, but display the actual values for "Area_planted" and "Crop_yield" items.
Here is the measure I’m using for the ratio:
```dax
Crop Ratio =
DIVIDE(
CALCULATE(
SUM('balance_sheet'[Value]),
'balance_sheet'[Items] = "Area_planted"
),
CALCULATE(
SUM('balance_sheet'[Value]),
'balance_sheet'[Items] = "Crop_yield"
),
0
)
And here is the measure to display values in the matrix:
TheTableMeasure =
IF(
SELECTEDVALUE('balance_sheet'[Items (groups)]) = "Crop",
[Crop Ratio],
[Actual Value Measure]
)
However, when I apply this, the "Area_planted" and "Crop_yield" rows show the same ratio value as the "Crop" group, instead of their actual values. How can I display the ratio only for the "Crop" group and the actual values for "Area_planted" and "Crop_yield"?
Thanks for your help!
Hi @muhammad_bens ,
Whether your problem has been resolved? If no, please update the formula of measure [Measurement table] as below and check if it can return the expected result...
Measurement table =
IF (
ISINSCOPE ( 'Balance'[Articles(Collections)] ),
IF (
SELECTEDVALUE ( 'Balance'[Articles(Collections)] ) = 'Crop',
[harvest report],
[Actual value measurement]
)
)
If the above one can't help you get the expected result, please provide some raw data in your tables(exclude sensitive data) with Text format and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:
How to provide sample data in the Power BI Forum
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Thank you aduguid for replying to my message. I had to make some changes to your code due to a context error, and this is the result:
Measurement table =
if (
ISINSCOPE('Balance'[Articles(Collections)]) && SELECTEDVALUE('Balance'[Articles(Collections)]) = 'Crop',
[harvest report],
[Actual value measurement]
)
It always shows the same result 😞
Pls let us know if the carry out group also contains area planted and crop yield data ?
thanks Rakesh for responding , no , carry out do not contains area planted and crop yield
Give this a try using INSCOPE
TheTableMeasure =
IF (
ISINSCOPE ( 'balance_sheet'[Items (groups)] ) && 'balance_sheet'[Items (groups)] = "Crop",
[Crop Ratio],
[Actual Value Measure]
)
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
11 | |
9 | |
6 |