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

Measure to return different columns depending on conditions

Hi all,

 

I am trying to do something like this

 

if the following conditon is met

Product is ship, the year is 2016 and the color is blue then the measure should take the value sales from table1

otherwise it should take the vale sales2 from table2.

 

Measure  = IF(and(and(product="Ships";year="2016");color="Blue");Table1[sales];table2[sales2])

 

It is incredible how much trouble this is giving me.

 

3 REPLIES 3
v-qiuyu-msft
Community Support
Community Support

Hi @kimrhansen,

 

Assume the Product, Year and Color comes from the Table1, please try to create a measure like below:

 

Measure = IF(and(and(MAX('Table1'[Product])="Ships",MAX('Table1'[Year])="2016"),MAX('Table1'[Color])="Blue"),SUM(Table1[sales]),SUM(Table3[Sales2]))

 

If it doesn't meet your requirement, please share sample data about those two tables for us to analyze.  

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Are these tables related?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
spuder
Resolver IV
Resolver IV

Hi @kimrhansen

 

is "ships", "color" and/or "year" part of one of those tables?

 

And should your result be only one number or will it be used in a visual that has more categories?

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.