Forum Discussion
Anonymous
3 years agoNot applicable
Change Duplicate Rows to Zero/Null - NOT Delete
Hi all, I'm hoping for a way to change duplicate rows to zero/null in Power Query/Dax . I have data which looks like the following: I need to have a unique value rather than duplicat...
- 3 years ago
see attached
https://1drv.ms/u/s!AiUZ0Ws7G26RhhxoO5MJGPHBG1zL?e=I6lIMBlet Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8krMUzAyVtBVcMpMrkzOSVXSgQoBGQih8IzU1BwgbWQAJEwMlGJ1iNUZnJpYAqQMSdbonJGYmQekTREa3VKT0DVChLC6FWylsQUJOqFuNSVVH8yphjCdsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Index = _t, Date = _t, Category = _t, Type = _t, #"Type Demand" = _t, #"Category Demand" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index", type text}, {"Date", type date}, {"Category", type text}, {"Type", type text}, {"Type Demand", Int64.Type}, {"Category Demand", Int64.Type}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Index", "Date", "Category Demand"}, {{"Count", each Table.AddColumn(Table.AddIndexColumn(_, "Index_2", 1,1), "Category_Demand", each if [Index_2] > 1 then 0 else [Category Demand]), type table }}), #"Removed Other Columns" = Table.SelectColumns(#"Grouped Rows",{"Count"}), #"Expanded Count" = Table.ExpandTableColumn(#"Removed Other Columns", "Count", {"Index", "Date", "Category", "Type", "Type Demand", "Category_Demand"}, {"Index", "Date", "Category", "Type", "Type Demand", "Category_Demand"}), #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Count",{{"Category_Demand", type number}}) in #"Changed Type1"exColumn(_, "Index", 1,1), "Score_2", each if [Index] > 1 then null else [SCORE]), type table }})
Ahmedx
3 years agoSuper User
- Ahmedx3 years agoSuper User
I also solved with Dax
- Anonymous3 years agoNot applicable
Sure but I'm just encountering an issue using the DAX - bascially it isn't picking up the [Category Demand] in the final line of code. I've tried multiple attempts but still nothing. If it isn't much a bother, illustrating how you did it with Power Query would be really helpful and would also I feel be more useful to do the transformation here.
- Ahmedx3 years agoSuper User
well watch the video and you will know how I could do it.
https://1drv.ms/v/s!AiUZ0Ws7G26RhiagoLqgNpMNzazK?e=go1gye