Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am trying to create a matrix in the following format, where the values is just 1 measure (computed from Volume column).
Expected result:
Sample data:
This is the code I came up with. The three columns, Beginning Inventory, Volume Received, and Variance, KL, all work as expected. But the Variance % does not show any values < variance % = _variance / (_begINV + volRCV) >. I believe this is due to the filters applied in the first 3 variables that interferes with the last variable. I would like to know if there is a way to revise my code to achieve this or should I just create 3 measures?
In-Plant Volume =
VAR _begINV =
CALCULATE(
SUM('Terminal In-Plant Performance'[Volume]),
'Terminal In-Plant Performance'[Attribute] = "Beginning Inventory, KL",
'Calendar'[Date] = MIN('Calendar'[Date])
)
VAR _volRCV =
CALCULATE(
SUM('Terminal In-Plant Performance'[Volume]),
'Terminal In-Plant Performance'[Attribute] = "Volume Received, KL"
)
VAR _variance =
CALCULATE(
SUM('Terminal In-Plant Performance'[Volume]),
'Terminal In-Plant Performance'[Attribute] = "Variance, KL"
)
RETURN
SWITCH(
SELECTEDVALUE('Terminal In-Plant Performance'[Attribute]),
"Beginning Inventory, KL",
_begINV,
"Variance, KL",
_variance,
"Volume Received, KL",
_volRCV,
"Variance (%)",
FORMAT(
DIVIDE(
FILTER(ALL('Terminal In-Plant Performance'[Attribute]),_variance),
FILTER(ALL('Terminal In-Plant Performance'[Attribute]),_begINV) + FILTER(ALL('Terminal In-Plant Performance'[Attribute]),_volRCV),
"-"
),
"Percent"
),
SUM('Terminal In-Plant Performance'[Volume])
)
@Anonymous , Try like
calculate(
DIVIDE(
_variance,
_begINV + _volRCV
), REMOVEFILTERS('Terminal In-Plant Performance'[Attribute]))
For formattin refer dynamic string formatting
https://powerbi.microsoft.com/en-us/blog/deep-dive-into-the-new-dynamic-format-strings-for-measures/
I tried this. Unfortunately, it didn't work. the whole Variance % column did not show up. the rest of the columns worked perfectly fine.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
72 | |
71 | |
57 | |
38 | |
36 |
User | Count |
---|---|
81 | |
67 | |
61 | |
46 | |
45 |