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
Anonymous
Not applicable

If row contains specific text, identify the other rows with the same ID

I'm trying to create a custom column where the row contains the word "Excel" in either column A or column B and then flag the ID's.  There will be cases where there are a group of three rows with the same ID but only one will have the word "Excel" in either column A or column B.  I want to make sure I get the all three instead of one.

 

Thank you in advance!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@Anonymous if you want to return same ID if col A or col B contains Excel in any of the row then use following measure and you can visual level filter where value is > 0

 

Measure = 
CALCULATE ( 
    COUNTROWS ( 'Table' ), 
    ALLEXCEPT ( 'Table', 'Table'[Id] ), 
    CONTAINSSTRING ( 'Table'[Column1], "Excel" ) || CONTAINSSTRING ( 'Table'[Column2], "Excel" )
)

 

@TheoC your solution will not work because if the same ID has two rows and only one row contains excel, it will not work and that seems to be the key requirement as far as I understood the post.

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 

  



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

9 REPLIES 9
parry2k
Super User
Super User

@Anonymous well you can easily create sample data in excel and import it in pbix file, you have to do some work to get the help. Not sure how to provide a solution without knowing the details. I hope someone else can help here.

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



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.

Anonymous
Not applicable

@parry2k My apologies.  I'm still pretty new to this but I'll make sure to create some sample data in the future.  It looks like filtering out the rows with blank IDs made everything work great.  Appreciate all your help!

parry2k
Super User
Super User

@Anonymous if you want to return same ID if col A or col B contains Excel in any of the row then use following measure and you can visual level filter where value is > 0

 

Measure = 
CALCULATE ( 
    COUNTROWS ( 'Table' ), 
    ALLEXCEPT ( 'Table', 'Table'[Id] ), 
    CONTAINSSTRING ( 'Table'[Column1], "Excel" ) || CONTAINSSTRING ( 'Table'[Column2], "Excel" )
)

 

@TheoC your solution will not work because if the same ID has two rows and only one row contains excel, it will not work and that seems to be the key requirement as far as I understood the post.

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

 

 

  



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.

Anonymous
Not applicable

Thanks @parry2k 

This almost works.  A row will either contain "Excel" in either column A or column B or could be absent from both.  There's a possibilty of "Excel" being in both columns.  I was able to get the measure to work and then filter everything greater than 0.  Looks like I'm pulling in blanks though.  There are a bunch of rows where "Excel" is not in column A and column B is completely blank.  

@Anonymous it should take care of those scenarios, can you paste the sample data in a table format or share pbix file and explain which is not working?



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.

Anonymous
Not applicable

Hi @parry2k ,

Unfortunately, I don't have any sample data I can share or a pbix file due to data sensitivity issues.

I looked into things more and when I set the measure filter to greater than 0, nothing is getting excluded which doesn't make sense.  The measure you suggested is fitting all the criteria I need.  Do we need to exclude where ID is blank?  Not sure if that would solve it or not

Hi @parry2k, great pick up mate! 

 

@Anonymous if you want the ID returned instead of a "1", just modify the solution provided by @parry2k to include an IF ( ISBLANK... ) such as below.

 

Measure =

VAR _Output1 = CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[Id] ), CONTAINSSTRING ( 'Table'[ColumnA], "Excel" ) || CONTAINSSTRING ( 'Table'[ColumnB], "Excel" ) )

RETURN

IF ( ISBLANK ( _Output1 ) , "" , 'Table'[ID] )

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

TheoC
Super User
Super User

Hi @Anonymous 

TheoC_0-1634078722119.png

 

FlagID = 

VAR _Keyword = "Excel"
VAR _ReturnKey = 'Table1'[ID]
VAR _ColumnA = 'Table1'[ColumnA]
VAR _ColumnB = 'Table1'[ColumnB]

RETURN

IF ( OR ( CONTAINSSTRING ( _ColumnA , _Keyword ) , CONTAINSSTRING ( _ColumnB , _Keyword ) ) , _ReturnKey , "" )

 

Hope it helps 🙂

If I have posted a response that resolves your question, please accept it as a solution to formally close the post.

Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!

Want to connect?www.linkedin.com/in/theoconias

Anonymous
Not applicable

Thanks @TheoC .  I tried to create this measue but as soon as I tried to do th VAR _ReturnKey, the ID would not show as an option.  Any idea why that would be?

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.

Top Solution Authors