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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
MichaelHutchens
Helper IV
Helper IV

Custom column in Power Query to check groupings of rows

Hi team, I'm hoping someone might be able to help.

I have a table showing various files ("URL" column), some with labels ("Label" column), and some without. Some files have multiple labels, and there are sometimes multiple rows for each file.

I need to create a custom column in Power Query that looks through each grouping of URLs and tells me whether the grouping contains a label or not. Here's an example of the output I need:

URLLabelContains Label
File1Lable.ArchivedYes
File2Label.CustomersYes
File2Label.ActiveYes
File3 Yes
File3Label.StaffYes
File3 Yes
File4 No
File4 No
File4 No
File5 No


Any help would really be appreciated 🙂

2 ACCEPTED SOLUTIONS
v-yangliu-msft
Community Support
Community Support

Hi  @MichaelHutchens ,

 

You can also use the dax function to.

Here are the steps you can follow:

1. Create calculated column.

Contains Label =
var _count=
COUNTX(FILTER(ALL('Table'),'Table'[URL]=EARLIER('Table'[URL])&&'Table'[Label]<>BLANK()),[Label])
return
IF(
    _count>=1,"Yes","No")

2. Result:

vyangliumsft_0-1669706701501.png

 

Best Regards,

Liu Yang

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

Thanks so much @v-yangliu-msft , that solutions works just fine 🙂 Appreciate your time!

View solution in original post

4 REPLIES 4
v-yangliu-msft
Community Support
Community Support

Hi  @MichaelHutchens ,

 

You can also use the dax function to.

Here are the steps you can follow:

1. Create calculated column.

Contains Label =
var _count=
COUNTX(FILTER(ALL('Table'),'Table'[URL]=EARLIER('Table'[URL])&&'Table'[Label]<>BLANK()),[Label])
return
IF(
    _count>=1,"Yes","No")

2. Result:

vyangliumsft_0-1669706701501.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Thanks so much @v-yangliu-msft , that solutions works just fine 🙂 Appreciate your time!

MichaelHutchens
Helper IV
Helper IV

Hi @amitchandak , thanks so much for responding. I'm getting an error with that code:

MichaelHutchens_0-1669651513124.png

 

amitchandak
Super User
Super User

@MichaelHutchens , Try a new column in power query

let
_col = [URL],
_table = Table.SelectRows(Ranges, each [URL] = _col and [Label] <> null ),
_count = if Table.RowCount(_table[Label]) >=1 then "Yes" else "No"
in
_count

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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