Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
trdoan
Helper III
Helper III

Measure returns wrong result

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)

01.JPG

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]

1.3.JPG

 

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.

Volume and sum.png

 

2. When I set "Order Quantity" as "Don't Summarise" and removed [Volume] from the data table, the result came out correctly.

dont summarise.png

 

3. But when I set "Order Quantity" as "Don't Summarise" and put back [Volume] to the data table, I got this:

1.4.png

 

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!

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

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



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.