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
arashaga
Helper I
Helper I

Return a vlaue from another column by condition

I have a column Major and I have another calculation called Filter Condition that checks to see if two of the slicers have checked before showing the values on the chart. I would like to use DAX to return the Major when the Filter Condition = "Yes" otherwise return a blank string. For example:

 

Value = If([Filter Condition]="Yes", myTable[Major], "") 

But DAX does not allow me to use myTable[Major] in there and I can only return a measure or calculation. How else I can acheive the same result?

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@arashaga,

 

You may just add MAX.

MAX ( myTable[Major] )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-chuncz-msft
Community Support
Community Support

@arashaga,

 

You may just add MAX.

MAX ( myTable[Major] )
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AlB
Super User
Super User

Hi  @arashaga

 

Is Value a measure? If so, you cannot use a naked column like myTable[Major] directly because there is no row context and therefore DAX does not know what value in myTable[Major] to choose.

 

Maybe if you place myTable[Major] in the rows of a matrix visual and use [Filter Condition]  as a visual level filter, showing the items with value Yes you'll get what you want? (I'm not sure I've completely understood your requirement).

Thanks @AlB, I think all I need is to know how to return a value of a colum row by row within an if condition. Is there anyway we could do this. As an exmaple(pseudo code):

 

If ( condition is met, myTable[Major], "")

@arashaga

 

Your initial code should be fine for that, if you are using it in a calculated column of myTable and everything in your code refers to myTable.

 

@AlB I get an error int he original formula asking to use aggregation such as max, min, etc.... I was wondering if there is a way to return the string value of that column.

@arashaga

Ok. I still don't know if Value is a column or a measure, what tables you have... Maybe if you share your pbix we'd be quicker

If it asks for an aggregation that means there's no row context where you are trying this

The value I am trying to return is a column containing string values. It is not a measure. I know with measures the formula would work. Thanks again.

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.