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.
Hi Folks,
I have the following data plotted in a matrix visual:
- Date[Year Month] - dim table
- Product[Item] - dim table
- Qty =
- Price - a measure that is calculated from the Fact Table.
- Volume = Price * Qty
Now, if you look at the total Volume for 202303 it is not equal to 75,307.05 + 186,871.76 = 262,178.81.
I want the total for the month to be equal to (Item1 Qty x Price1) + (Item2 Qty x Price2)
where Qtys is the sum of Cost[QUANTITY_STD] for all periods for the respective item.
At the end, I will need to plot the Volume measure into a chart with dimension Year Month and the value for March 2023 should be 262,178.81 when Item 1 and Item 2 are selected from the Item slicer.
How can I achieve this?
P. S. I have added a link with a file with sample data in the comment below. I think it will make it easier to understand the problem.
Solved! Go to Solution.
Here is the DAX code that returns correct result:
SUMX(
SUMMARIZE(
'FACT',
'Date'[Year Month],
'FACT'[FK_PRODUCT],
"price__", [Price_]
),
[price__] * CALCULATE(
[Qty],
REMOVEFILTERS('Date'[Year Month])
)
)
There are 2 things which are interesting for me and I cannot fully understand:
1. If you put ALLSELECTED in the CALCULATE statement, instead of REMOVEFILTERS, the result is wrong.
2. If you define Qty measure as a variable inside the measure, the result is wrong is well.
Here is the DAX code that returns correct result:
SUMX(
SUMMARIZE(
'FACT',
'Date'[Year Month],
'FACT'[FK_PRODUCT],
"price__", [Price_]
),
[price__] * CALCULATE(
[Qty],
REMOVEFILTERS('Date'[Year Month])
)
)
There are 2 things which are interesting for me and I cannot fully understand:
1. If you put ALLSELECTED in the CALCULATE statement, instead of REMOVEFILTERS, the result is wrong.
2. If you define Qty measure as a variable inside the measure, the result is wrong is well.
@Quiny_Harl , Not very clear. But of the price is related item table on 1 side
you need a measure like
SUMX(Cost, cost[QUANTITY_STD]* related(item[price] ))
The information you have provided is not making the problem clear to me. Can you please explain with an example.
Appreciate your Kudos.
@amitchandak, thank you for your reply.
Here is a sample file: https://filetransfer.io/data-package/ZD3DY2wL#link
If you look at the highlighted example.
(5696 x 7) + (1701 x 32) =
39,872 + 54,432 = 94,304
However, instead of this total, we have 288,483 for Year Month 202211, which is wrong.
How can I make the total Volume equal to 94,304 and this value should be the same for all 3 visuals (meaning regardless if Item is used as a dimension or not)?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |