The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event! Join us in Stockholm, Sweden from September 24-27, 2024.
2-for-1 sale on June 20 only!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello everyone,
Here is the link to my sample data.
Please note in the "Data" table, each Part Number corresponds to a COE Description and there are a total of 5 COE Descriptions.
Table "Data" and "OPR" are linked by Part Number and Material Number columns.
The "OPR" table is a transaction table where everything is recorded during the last 12 months whilst the "Data" table contains the Part Numbers I want to track to see whether Supplier WF and SOA had shared any Part Numbers mentioned in the "Data" table.
I did the below steps (not sure if they're right):
1. I merged the OPR and Data table, left outer join, by 'Data'[Part Number] and 'OPR'[Material Number] and called the table 'Merge Table'
2. I came up with this calculated column to find the Shared Material Numbers between WF and SOA, though I'm not sure the 'Merge Table'[Material Number] or the 'Merge Table'[Part Number] already did the job(?)
Please help me validate if merging the 2 tables already did the job of finding which Part Numbers they shared? Or the below measure would do/would not do the job?
Common P/Ns = VAR _MN = CONTAINS( FILTER('Merge Table', 'Merge Table'[Vendor Name] = "SOA"), 'Merge Table'[Material number],'Merge Table'[Material number] ) && CONTAINS( FILTER('Merge Table', 'Merge Table'[Vendor Name] = "WF"), 'Merge Table'[Material number], 'Merge Table'[Material number] ) RETURN IF(_MN = TRUE, 'Merge Table'[Material number] , "")
3. I created the following measures to calculate Spend, Volume, and Average Final Run Time (known as TAT):
SPEND = CALCULATE( SUM( 'Merge Table'[Net Order Quantity] ), CALCULATETABLE( VALUES( 'Merge Table'[Material number] ), 'Merge Table'[Vendor Name] = "SOA" ), CALCULATETABLE( VALUES( 'Merge Table'[Material number] ), 'Merge Table'[Vendor Name] = "WF" ))
VOLUME = CALCULATE( SUM( 'Merge Table'[Order Quantity] ), CALCULATETABLE( VALUES( 'Merge Table'[Material number] ), 'Merge Table'[Vendor Name] = "SOA" ), CALCULATETABLE( VALUES( 'Merge Table'[Material number] ), 'Merge Table'[Vendor Name] = "WF" ))
TAT = CALCULATE( AVERAGE( 'Merge Table'[Net Order Quantity] ), CALCULATETABLE( VALUES( 'Merge Table'[Material number] ), 'Merge Table'[Vendor Name] = "SOA" ), CALCULATETABLE( VALUES( 'Merge Table'[Material number] ), 'Merge Table'[Vendor Name] = "WF" ))
4. Because I wanted to have a dynamic chart where it can show Volume, Spend, and Average Final Run Time simultaneously, I created a new table called "Measure Selection" (see the below picture)
and the following measures:
Selected Metric = SELECTEDVALUE( 'Measure Selection'[Selected Measure], "SPEND" )
Selection = SWITCH(TRUE(), 'Measure Selection'[Selected Metric] = "SPEND", [SPEND], 'Measure Selection'[Selected Metric] = "TAT", [TAT], 'Measure Selection'[Selected Metric] = "VOLUME", [VOLUME], BLANK() )
5. I created a Clustered column chart and a chiclet slicer using 'Measure Selection'[Selection]
However, the result wasn't quite accurate. When I examined April 2018's calculations using a Data table, I noticed a couple of things:
1. In my original dataset, Supplier SOA's Volume in April 2018 only had 7 units whilst my [Volume] measure showed 14.
In the below photo, I set "Order Quantity" as "Sum" and it gave 14 units and matched the [Volume] measure's result. Still, both of them should have showned 7.
2. When I set "Order Quantity" as "Don't Summarise" and removed [Volume] from the data table, the result came out correctly.
3. But when I set "Order Quantity" as "Don't Summarise" and put back [Volume] to the data table, I got this:
All these calculations really wrecked my mind. Does anyone have any idea why my measure(s) did not calculate correctly? Please show me how to fix this. Thank you very much!
This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Hi @Greg_Deckler , thanks for your response. I tried your measures but it didn't seem to work on mine.
The measure still returned 14 instead of 7.
Here is the link to my sample pbi. Can you please take a look at it? Thanks a lot!
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 |
---|---|
102 | |
97 | |
80 | |
62 | |
57 |
User | Count |
---|---|
264 | |
120 | |
115 | |
83 | |
70 |