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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.