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
malw
Frequent Visitor

DAX: Measure SUM only if Column="SomeValue"

I've got what is I assume a simple DAX problem.

 

I'm trying to SUM the number of Events in my 'Events'[CurrentValue] field only when the related 'Event Type'[Event Sub Type]="Digital Calls"

 

I tried:

 

Digital Call Minutes:=CALCULATE(SUM(Event[Current Value]),FILTER(Event, 'Event Type'[Event Sub Type]="Digital Call"))

but that throws the following error:

 

 

Warning Measure 'Measure'[Digital Call Minutes] : A single value for column 'Event Sub Type' in table 'Event Type' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result. 

 

THe reason I'm doing this is because the Current Value field has multiple data types depending on the Event Sub Type - so I can't just SUM every Event Sub Type as it'll error out. All I want to do is restrict the SUM to a particular subset. I gather I'm missing something simple here!!

 

Edit: I should add the Event -> Event Type tables are Many to One with bi-directional filtering turned on. So each Event will have only one Event Type/SubType

1 ACCEPTED SOLUTION

Your filter function is operating over the Event table (first parameter), but then you are applying a filter from the 'event type' table. Try changing the first parameter to be 'event type'



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

View solution in original post

2 REPLIES 2

Your filter function is operating over the Event table (first parameter), but then you are applying a filter from the 'event type' table. Try changing the first parameter to be 'event type'



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Thanks Matt, that did the trick. I also had to change it to SUMX so I could convert the values to ints from strings.

 

I ended up with the following, which has worked:

 

Digital Call Minutes:=CALCULATE(SUMX(Event,VALUE(Event[Current Value])/60),FILTER('Event Type', 'Event Type'[Event Sub Type]="Digital Call"))

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.