Forum Discussion
Categories And Or
- Anonymous4 years ago
Hi Caracole ,
In order to provide you with a suitable solution, could you please provide some sample data (with expense and category information) and the final result you want without sensitive info? If there is an expense of $600 that is recorded in the [leisure, food] category, then in the end you would like to calculate it in the food (600/2=300) and leisure (600/2=300) categories respectively? If so, I created a sample file(see attachment) for you and see if it is what you want...
1. Split the category column in Power Query Editor
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dZCxDoMwDER/pcocidgpEH6gE1u7IQZEI5UlqZLy/20QcRJRFi/vfD7fMDCsoEKByDhDIX7z4Sbj39Z9PBt54Bg5YOA3a587kZHIbbPXi1+d5pdMcqVlGST33Limw7AZL2Yys460IXNVmPermV+7piUHeRZAkaQ7BOjSZ3gMAIJwq/4VA1D+n12FVFrdnKUHmQpQxf3xCw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Expense = _t, Category = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Expense", Int64.Type}, {"Category", type text}}), #"Split Column by Delimiter" = Table.TransformColumns( Source, {"Category", each Text.Split(_,", "), type list}), #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Expense", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type1", "NExpense", each [Expense] / List.Count( [Category] )), #"Expanded Category" = Table.ExpandListColumn(#"Added Custom", "Category"), #"Removed Columns" = Table.RemoveColumns(#"Expanded Category",{"Expense"}), #"Changed Type2" = Table.TransformColumnTypes(#"Removed Columns",{{"NExpense", Int64.Type}, {"Date", type date}, {"Category", type text}}) in #"Changed Type2"2. Create a treemap visual with processed data
Best Regards
Caracole , I think you have to create new column using switch or if
- Caracole4 years agoNew Member
Hi thank you for your answer,
I tried to create a new column with SWITCH function but it only solve partially the problem.
For exemple if i write (...,"Loisir, Midi","Loisir",...) the categorie will count "Loisir, Midi" as "Loisir" but not at "Loisir" and "Midi".
Same way if i write (...,"Loisir, Midi","Midi",...) I'll only have "Midi" in my new column.
I've tried to write (...,"Loisir, Midi","Loisir","Loisir, Midi","Midi",...) but it count only the first one ..