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

Detect No before Yes

Hello,

 

I am trying to create a new measure or calculated column that will detect if "no" exists before "yes" within a row.  If this instance does exist, the value would equal "1" or "true", and if this instance does not exist within that row, the value would equal "no" or "false".  There are a total of 23 columns.  Other values would possibly exist within this row , like "N/A" for example, but these would not matter when it comes to the result of no before yes.  

 

Note:  The no would not need to exist directly before the yes.  For example, the row could read "No" "No" "Yes" "N/A" "No" "Yes"

Simply because a no reads before a yes within the row, the value would have to be "1" or "true".

 

true.png

Please help by providing a calculated column or a measure, thank you in advance.

 

1 ACCEPTED SOLUTION
ImkeF
Super User
Super User

In the query editor, you add a column with this formula:

 

List.PositionOf(Record.FieldValues(_), "No") < List.PositionOf(Record.FieldValues(_), "Yes")

if you need a case-insensitve check, you transfer to lower like this:

 

List.PositionOf(Record.FieldValues(Text.Lower(_)), "no") < List.PositionOf(Record.FieldValues(Text.Lower(_)), "yes")

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Super User
Super User

In the query editor, you add a column with this formula:

 

List.PositionOf(Record.FieldValues(_), "No") < List.PositionOf(Record.FieldValues(_), "Yes")

if you need a case-insensitve check, you transfer to lower like this:

 

List.PositionOf(Record.FieldValues(Text.Lower(_)), "no") < List.PositionOf(Record.FieldValues(Text.Lower(_)), "yes")

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.