Forum Discussion

Justas4478's avatar
Justas4478
Icon for Post Prodigy rankPost Prodigy
1 year ago
Solved

Creating custom column if specific values from two other column are expected result

Hi, I have two columns storage and destination. And there are many reasons for stock being moved from storage to destination. Depending on storage and destination it can have different description....
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Justas4478 

     

    Thank you rajendraongole1 for the great reply. If this has helped you solve your problem, please consider accepting rajendraongole1's reply as a solution.


    Here are some of my suggestions that I hope will help you.
    1. Write dynamic rules in the Power Query editor using the M language. Example:

    = Table.AddColumn(
        PreviousStep,
        "Description",
        each if [Storage] = "X" and [Destination] = "Y" then "Z"
             else if [Storage] = "A" and [Destination] = "B" then "C"
             else "Default Description"
    )


    2. If the combinations are very large and may change dynamically, it is recommended to maintain an external mapping table (e.g. Excel or database) with storage, destination and corresponding description. Then import the mapping table into Power BI. Use the MERGE function to join the master table to the mapping table and find the description based on storage and destination.

     

    Best Regards,
    Jarvis Tang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.