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

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.

Reply
Erwin
Helper II
Helper II

Incorrect Measure Total

Dear all,

 

Please review below table.

 

Order          Object       Amount

1A10
2A15
3A5
4A20
4B5
4C10
4D25
5B5
6B5
7C10
8D35
9D15
10C5

 

I would like to filter out all orders with a relation to more than 1 object. As you can see this is only true for Order #4.

 

I have created the following measure:

Sum of Orders >1 Object :=
SUMX (
    FILTER ( Data, COUNTROWS ( VALUES ( Data[Object] ) ) > 1 ),
    Data[Amount]
)

 

This code works, as it filters out Order #4 when orders are expanded in the pivottable. However, the measure total still shows the total value of the Amount column. Obviously this is due to the fact that, in the total row, there is no context for Order and the expression is calculated over the entire table.

 

I know I need to use HASONEVALUE to be able to write different code for the calculation of the total value. I just can't come up with the correct code.

 

Sum of Orders >1 Object:=IF(
HASONEVALUE(Data[Order]),
        SUMX (
             FILTER ( Data, COUNTROWS ( VALUES ( Data[Object] ) ) > 1 ),
             Data[Amount]
         ),
        ?????? What goes here???
)

Can you help me with this?

 

Rg. Erwin

1 ACCEPTED SOLUTION

@Erwin

 

Try creating another measure as follows

 

Measure =
IF (
    HASONEVALUE ( Data[Order] ),
    [Sum of Orders >1 Object],
    SUMX ( VALUES ( Data[Order] ), [Sum of Orders >1 Object] )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
sokg
Solution Supplier
Solution Supplier

What number to you expect to show in total???

My guess is that you want nothing so you write

 

BLANK()

@Erwin

 

Try creating another measure as follows

 

Measure =
IF (
    HASONEVALUE ( Data[Order] ),
    [Sum of Orders >1 Object],
    SUMX ( VALUES ( Data[Order] ), [Sum of Orders >1 Object] )
)

Regards
Zubair

Please try my custom visuals

That did the trick! Guess I was thinking in circles and it was actually simpler than I thought.

 

Thanks!

Erwin

sokg
Solution Supplier
Solution Supplier

Glad to help you!!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.