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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
MJBLACK
New Member

filter on a text field

Hello,

 

I have a simple table that includes a column named "purchunit." I want to iterate through the rows and determine if this field has a value of "LB" or "CS".  I thought the following measure (PriceUOM) would work, but it always returns false. Below is a screen shot of my measure and the table

 

Any ideas? 

Thank you

 

PriceUOM =
IF(UPPER(MAX(purchline[PurchUnit]))="LB","true","false")

 

MJBLACK_0-1691515160084.png

 

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@MJBLACK when you add a column it is always in the row context, so add a column, and don't use any aggregate function, did you try what I provided?

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
parry2k
Super User
Super User

@MJBLACK sounds good. 

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@MJBLACK when you add a column it is always in the row context, so add a column, and don't use any aggregate function, did you try what I provided?

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi parry2K

Here is the column I created:

MJBLACK_0-1691518769153.png

 

Here are the results of the formula. It always returns false.

MJBLACK_1-1691518840020.png

 

Thank you

It appears that your solution does in fact work properly. I converted to upper and the following worked.  

PriceUOM Column = if(upper(purchline[PurchUnit]) = "LB","true","false")
 
I will do some more testing and will flag as resolved.
thanks
 
parry2k
Super User
Super User

@MJBLACK I would recommend using PQ to add a new column but if you want to use DAX for whatever reason then do this:

 

PriceUOM Column = 
IF ( purchLine[PurchUnit] = "LB", "true", "false" )

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤️



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hello,

If this is a column, how does DAX know what the row context is?  It appears to yield the same result as what I tried to do.

Thanks

AbhinavJoshi
Responsive Resident
Responsive Resident

Hello @MJBLACK. You can achieve this through conditional column in Power Query M. Please see the sceenshot and code attached. 

AbhinavJoshi_0-1691516628946.png

= Table.AddColumn(#"Changed Type", "PriceUOM", each if [PurchUnit] = "LB" then true else if [PurchUnit] = "CS" then true else false)

 

I hope it helps!

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.