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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Danielnir
Helper II
Helper II

Use some cell values as categories for other values from the same column

Hi,

 

I have Profit and Loss data coming from the server. I need to use some of the values in one column as a category for other values from the same column. Is it possible to do such thing without creating a conditional column? Data tend to be fluid so I would like to avoid manually changing it each time.

 

The column looks like this:

Problem.jpg

Hope it makes sense. 

 

May I ask for your assistance?

5 REPLIES 5
BA_Pete
Super User
Super User

Hi @Danielnir ,

 

I think you'll have to use a conditional column in order to pick out your header values for later use.

I'd create a custom column first, like this:

 

if List.Contains({"Sales", "Purchases", "Direct Expenses", "Something Else Etc"}, [Title])
then [Title] else null

 

 

From here, you can just select your new custom column and go to the Transform tab > Fill (dropdown) > Down.

You now have the headers alongside the relevant rows which you can further filter/transform for more detailed needs.

 

Example output:

BA_Pete_0-1669370799687.png

 

Example code:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk7MSS1WitWJVtJFAmAB5/y8kqLE5BIFhBrfzOJkBc+85PzcVDA/KKbUwMDIzAXMARMBpUXJGYnFuMz0TSxJLcpMzCmG2pBbkJ+XmldSjDDAJbMoFWina0VBah5OY3wSk/JLi2Bm5GYWF2fm54G5wSX5RYnpQNfFAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Title = _t]),
    addConditionalCol = Table.AddColumn(Source, "header", each if List.Contains({"Sales", "Purchases", "Direct Expenses", "Something Else Etc"}, [Title])
then [Title] else null),
    fillDown = Table.FillDown(addConditionalCol,{"header"})
in
    fillDown

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi @BA_Pete,

 

thanks for your quick reply. Unfortunately, the solution didn't work for me as there are many unique values and nearly none of them consist of words that would contain a category name in them.

 

I think that I will have to force myself to write a long conditional column and also use excel to first categorise everything by hand. Ech..

 

Hold your horses my man! Where there's a will, there's a way.

Was my broad understanding of your requirement correct - do you essentially want that output, but without hard-coding the header names?

If so, then do the header names that you want carried down ALWAYS have a '----------' row directly underneath them? We could use this characteristic to dynamically identify them.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Yeah, that data isn't very clean and no, not all categories have "-------" beneath them. I don't want to waste your time I will go for creating a massive conditional column.

 

I'm going to use excel for this as it will help me get the m language formula together. I will achieve that by writing parts of code in each column and then using "concat" function to bring it all together. No running away from hard categorising the data first I think 😄

 

Just thought that there is a button or other super simple solution that I wasn't aware of.

 

Thanks for your willingness to help,

Daniel

 

No problem, best of luck 👍

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors