March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi everyone,
I really need help on building an expression that i can't get it to work properly.
i have the following star schema (coloured fields are the connected ones).
The two unrelated tables (Dim_Proc_forecast_versions...) are there to calculate the same expression twice.
I want to compare two versions to determine the impact on each component for the selected "Material_Code" (one or more from the slicer on Dim_PH123). I need to obtain the final volume from the "SourceData" table, the amount per component from the "Exploded BOM" table, and the price from the "Procurement Forecast" table.
The expression should compute: Final volume * Amount * Price difference.
The formula I wrote works perfectly well on each component but the total is not OK. I am frying my brain but nothing I change works. Can you please help me?
"
See example below:
Volume for "Material 1" is 503 kg and for "Material 2" is 15 kg
The table i get is:
(the volumes are not right there)
Thanks for your help!!!!!!!
Hi @rajendraongole1 ,
thanks for your help!!!!. it doesn't work well. I created a simplified version of the file. I'd really appreciate it if you can take a look into it:
https://drive.google.com/file/d/1sqs3HbmrcoTz4pyNVYd5WyG0bLOp-ynt/view?usp=sharing
Thanks!
nico
Hi @nicoenz - Adjusting the calculation to ensure the aggregation respects the total context.
Price Impact RM =
VAR SelectedVersion1 = SELECTEDVALUE(Dim_Procurement_forecast_versions_RM1[Version])
VAR SelectedVersion2 = SELECTEDVALUE(Dim_Procurement_forecast_versions_RM2[Version])
VAR FinalVolumeKG = CALCULATE(SUM(SourceData[Final_Volume_KG]))
VAR AmountPerComponent = CALCULATE(SUM('Exploded BOM'[Amount]))
VAR PriceDifference =
CALCULATE(
SUMX(
'Procurement forecast',
VAR Price1 = CALCULATE(
SUM('Procurement forecast'[Price]),
FILTER(
ALL('Procurement forecast'[PriceType]),
'Procurement forecast'[PriceType] = SelectedVersion1
),
FILTER(
ALL('Procurement forecast'[Version]),
'Procurement forecast'[Version] = SelectedVersion1
)
)
VAR Price2 = CALCULATE(
SUM('Procurement forecast'[Price]),
FILTER(
ALL('Procurement forecast'[PriceType]),
'Procurement forecast'[PriceType] = SelectedVersion2
),
FILTER(
ALL('Procurement forecast'[Version]),
'Procurement forecast'[Version] = SelectedVersion2
)
)
RETURN Price1 - Price2
)
)
RETURN
SUMX(
VALUES(Dim_PH123[Material_Code]),
FinalVolumeKG * AmountPerComponent * PriceDifference
)
This structure should maintain correct values for each component row and the grand total.
Hope this helps , and let me know if any
Proud to be a Super User! | |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
133 | |
90 | |
88 | |
64 | |
58 |
User | Count |
---|---|
203 | |
141 | |
107 | |
73 | |
70 |