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

Create a custom column that show as text if the line is "Record" or "List"

I have a column in which the values are given as "list" and "record", I cannot pre filter it, the data is given me as such.

 

I would need to be able to filter out lists and records, how can i do that ?

 

I thought of making a custom column that gives if the line is a list or a record in text so i can filter out, if their a way to do it ?

 

Exacrion_0-1670582780856.png

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please refer to my code and sample.

Whole M Code:

let
    Source = Table.Combine({Table, List, Record}),
    #"Added Custom" = Table.AddColumn(Source, "Custom.1", each Table.SelectRows([Custom])[Column1]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Custom.1"}),
    #"Added Custom1" = Table.AddColumn(#"Removed Columns", "Table", each if 
Table.ColumnCount([Custom]) <> Error.Record
then 
"Table"
else
"Record"),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "List", each if
List.Count([Custom]) <> Error.Record
then
"List"
else
""),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Record", each if
Record.ToList([Custom]) <> Error.Record
then
"Record"
else
""),
    #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Custom3", {{"Table", ""}}),
    #"Replaced Errors1" = Table.ReplaceErrorValues(#"Replaced Errors", {{"List", ""}}),
    #"Replaced Errors2" = Table.ReplaceErrorValues(#"Replaced Errors1", {{"Record", ""}}),
    #"Added Custom4" = Table.AddColumn(#"Replaced Errors2", "Combine", each if [Table] = "" 
then 
if [List] = "" 
then 
[Record]
else 
[List]
else
[Table])
in
    #"Added Custom4"

Result is as below.

RicoZhou_0-1670838891959.png

I think [Combine] column is the result you need.

 

Best Regards,
Rico Zhou

 

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

5 REPLIES 5
VijayP
Super User
Super User

@Anonymous 

Go to power query edtior and filter that data!




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Anonymous
Not applicable

I am already on power query, my problem is that i want to filter out the data but i cannot as power query refuses to consider lines showing as "List" and "Record" lines as filter targets

 

Exacrion_0-1670584938011.png

 

Hi @Anonymous ,

 

Please refer to my code and sample.

Whole M Code:

let
    Source = Table.Combine({Table, List, Record}),
    #"Added Custom" = Table.AddColumn(Source, "Custom.1", each Table.SelectRows([Custom])[Column1]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Custom.1"}),
    #"Added Custom1" = Table.AddColumn(#"Removed Columns", "Table", each if 
Table.ColumnCount([Custom]) <> Error.Record
then 
"Table"
else
"Record"),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "List", each if
List.Count([Custom]) <> Error.Record
then
"List"
else
""),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Record", each if
Record.ToList([Custom]) <> Error.Record
then
"Record"
else
""),
    #"Replaced Errors" = Table.ReplaceErrorValues(#"Added Custom3", {{"Table", ""}}),
    #"Replaced Errors1" = Table.ReplaceErrorValues(#"Replaced Errors", {{"List", ""}}),
    #"Replaced Errors2" = Table.ReplaceErrorValues(#"Replaced Errors1", {{"Record", ""}}),
    #"Added Custom4" = Table.AddColumn(#"Replaced Errors2", "Combine", each if [Table] = "" 
then 
if [List] = "" 
then 
[Record]
else 
[List]
else
[Table])
in
    #"Added Custom4"

Result is as below.

RicoZhou_0-1670838891959.png

I think [Combine] column is the result you need.

 

Best Regards,
Rico Zhou

 

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

 

VijayP
Super User
Super User

@Anonymous Question is not clear , if you can filter with custom column why cant you filter when the data is in the raw format. what is the business logic




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Anonymous
Not applicable

I cannot i do not have access to the raw data, it is given me as such via an api

 

Is there a function that would give something like "If column is a record type then "record", else "list" ?

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors