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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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