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
danielfynesam2
New Member

Measure calculating Conditional SUM according to Values from another Table Not Filtering As Expected

I have a Production Table with Tons and Meters and I have an Asset Table with a Site Column and an Asset Group Type Column. I've got a requirement for a measure to show Tons for certain Asset Group Types and show Meters for other Asset Group Types. I've been able to do a DAX query that does this, but if I try and slice on Site, my values of production (tons and meters) don't slice, they only show the total. There is a relationship between the Production Table and the Asset Table on Site. Here is my DAX query for the calculated measure on my Production table.
 

Tons/Meters =
IF (
VALUES ( Asset[AssetGroupType] ) IN { "AssetType1", "AssetType2" },
SUM ( Production[Tons] ),
SUM ( Production[Meters] )
)

 

 

 

 Production Table:

SiteTonsMeters
Site11005
Site220010
Site330015


Asset Table:

AssetAssetTypeSite
Asset1AssetType1Site1
Asset2AssetType2Site1
Asset3AssetType3Site1
Asset4AssetType3Site2
Asset5AssetType1Site2
Asset6AssetType2Site3
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@danielfynesam2 

Please try

Tons/Meters =
SUMX (
    VALUES ( Asset[AssetGroupType] ),
    IF (
        Asset[AssetGroupType] IN { "AssetType1", "AssetType2" },
        SUM ( Production[Tons] ),
        SUM ( Production[Meters] )
    )
)

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

@danielfynesam2 

Please try

Tons/Meters =
SUMX (
    VALUES ( Asset[AssetGroupType] ),
    IF (
        Asset[AssetGroupType] IN { "AssetType1", "AssetType2" },
        SUM ( Production[Tons] ),
        SUM ( Production[Meters] )
    )
)
JohnShepherdAPD
Helper II
Helper II

Try wrapping the sum inside the calculate function:

IF (
VALUES ( Asset[AssetGroupType] ) IN { "AssetType1", "AssetType2" },
CALCULATE(SUM ( Production[Tons] )),
CALCULATE(SUM ( Production[Meters] ))
)

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.

Top Solution Authors