Forum Discussion

DanFromMontreal's avatar
4 years ago
Solved

Modifing data based on a correction table

Hello dear Power BI community, I've got a good challenge that I was unable to resolve and/or find the right approach to modify several data in a table. I have a table (tblData) containing more than...
  • v-kkf-msft's avatar
    4 years ago

    Hi DanFromMontreal ,

     

    Please try the following code:

     

    let
    
        #"Unpivot tblData" = Table.UnpivotOtherColumns(tblData, {"RowID"}, "Attribute", "Value"),
        #"Unpivot tblCorrection" = Table.UnpivotOtherColumns(tblCorrection, {"RowID"}, "Attribute", "Value"),
        Source = Table.NestedJoin(#"Unpivot tblData", {"RowID", "Attribute"}, #"Unpivot tblCorrection", {"RowID", "Attribute"}, "tblCorrection", JoinKind.LeftOuter),
        #"Expanded tblCorrection" = Table.ExpandTableColumn(Source, "tblCorrection", {"Value"}, {"tblCorrection.Value"}),
        #"Added Custom" = Table.AddColumn(#"Expanded tblCorrection", "Custom", each if [tblCorrection.Value] = " " or [tblCorrection.Value] = null then [Value] else [tblCorrection.Value]),
        #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Value", "tblCorrection.Value"}),
        #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Attribute]), "Attribute", "Custom")
    in
        #"Pivoted Column"

     

    If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
    Best Regards,
    Winniz
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.