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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Top Kudoed Authors