Forum Discussion
SteveBrou
6 years agoFrequent Visitor
Extract Different Slicers from a Column
I have a table of salary information for the US. There is a lot of information in this table but 2 of the notable columns are labor category and Geography. It is the Geography column where I am runni...
- 6 years ago
One way is to add three columns with IF in Power Query see code and pics. And as you said you could use Distinct
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathanielet Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckzKzEnNS9UJqVCK1YlWcsvJL8pMSVTQCC5JLEnVBIuFpxaXKGgEpaZn5ucBRWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Geography = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Geography", type text}}), #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "State", each if Text.Contains([Geography], "(State)") then [Geography] else ""), #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "Region", each if Text.Contains([Geography], "(Region)") then [Geography] else ""), #"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1", "Metro", each if [State] = "" and [Region] = "" then [Geography] else ""), #"Changed Type1" = Table.TransformColumnTypes(#"Added Conditional Column2",{{"State", type text}, {"Region", type text}, {"Metro", type text}}) in #"Changed Type1"
Nathaniel_C
6 years agoCommunity Champion
One way is to add three columns with IF in Power Query see code and pics. And as you said you could use Distinct
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
et
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckzKzEnNS9UJqVCK1YlWcsvJL8pMSVTQCC5JLEnVBIuFpxaXKGgEpaZn5ucBRWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Geography = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Geography", type text}}),
#"Added Conditional Column" = Table.AddColumn(#"Changed Type", "State", each if Text.Contains([Geography], "(State)") then [Geography] else ""),
#"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "Region", each if Text.Contains([Geography], "(Region)") then [Geography] else ""),
#"Added Conditional Column2" = Table.AddColumn(#"Added Conditional Column1", "Metro", each if [State] = "" and [Region] = "" then [Geography] else ""),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Conditional Column2",{{"State", type text}, {"Region", type text}, {"Metro", type text}})
in
#"Changed Type1"SteveBrou
6 years agoFrequent Visitor
Thanks Nathaniel - that did the trick!
- Nathaniel_C6 years agoCommunity Champion
Sweet!