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
casea14
Regular Visitor

Help with IF function

Hi There!

I have two calculated measures  -- one that correctly calculates the Avg Market Turn % for Even Years and another that correctly calculates the Avg Market Turn % for Odd Years.

Example - Odd.PNGExample - Even.PNG

 

 

But now I would like a single measure that calculates the same thing. I was thinking something like the following IF function with the above Even Year calculation as the ResultIfTrue part of the IF function and the above Odd Year calculation as the ResultIfFalse part of the IF function...... but then I get the below error message. (excuse the bad DAX formatting)

 

ERROR: "A single value for column 'E/O' in table 'Dates_Key' 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"

 

Can anyone help me with this or offer any workarounds? Thank you!

Example -Even_ Odd.PNG

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @casea14

 

At the beginning of your formula, use SELECTEDVALUE

 

i.e. replace   IF(Dates_Key[E/O]="Even"

 

with

 

IF(selectedvalue(Dates_Key[E/O])="Even"


Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @casea14

 

At the beginning of your formula, use SELECTEDVALUE

 

i.e. replace   IF(Dates_Key[E/O]="Even"

 

with

 

IF(selectedvalue(Dates_Key[E/O])="Even"


Regards
Zubair

Please try my custom visuals

Hi @Zubair_Muhammad

That's it!!! Thank you! Your solution also helped me with another similar issue. Very much appreciated!

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.