Forum Discussion
AshleyMartinez
6 years agoFrequent Visitor
DAX match text in multiple columns
Hi, I've been trying to figure out how can I get this report done but I can't find any efficient way to fo it. I have 2 tables: [Table1] Sales by brand and date: Brand Date Sales Apple...
Nathaniel_C
6 years agoCommunity Champion
Hi AshleyMartinez , smpa01 ,
Automated change in PQ.
let
Source = Excel.Workbook(File.Contents("C:\Users\nat_c\OneDrive\Desktop\SalesBrand.xlsx"), null, true),
Brand_Table = Source{[Item="Brand",Kind="Table"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Brand_Table,{{"Brand", type text}, {"City Agent", type text}, {"Region Agent", type text}, {"Country Agent", type text}, {"Head of Account", type text}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Brand"}, "Attribute", "Value"),
#"Removed Columns" = Table.RemoveColumns(#"Unpivoted Columns",{"Attribute"}),
#"Merged Columns" = Table.CombineColumns(#"Removed Columns",{"Brand", "Value"},Combiner.CombineTextByDelimiter(",", QuoteStyle.None),"Merged"),
#"Removed Duplicates" = Table.Distinct(#"Merged Columns"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Removed Duplicates", "Merged", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Merged.1", "Merged.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Merged.1", type text}, {"Merged.2", type text}}),
#"Renamed Columns1" = Table.RenameColumns(#"Changed Type1",{{"Merged.1", "Brand"}, {"Merged.2", "Emp"}}),
#"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns1",{"Emp", "Brand"}),
#"Sorted Rows" = Table.Sort(#"Reordered Columns",{{"Emp", Order.Ascending}, {"Brand", Order.Descending}})
in
#"Sorted Rows"Went from
to this,
So this at least is automated vs the if statement.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
- Nathaniel_C6 years agoCommunity Champion