Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

DAX or Power Query - Creating a new column with values from another column

Hi everyone,

 

I'm facing a problem and decided to ask the community for help.

 

I have a table with 3 columns - [Country ID], [Factory ID], and [Amount] - and I want to add a new column [Amount (new)] with the logic that's displayed on the example below. What's the best way to achieve this by using either DAX or PowerQuery?

 

Thank you!

 

Country IDFactory IDAmountAmount (new)
11 €   432,00 €             432,00
11 €   432,00 
11 €   432,00 
11 €   432,00 
12 €   869,00 €             869,00
12 €   869,00 
12 €   869,00 
12 €   869,00 

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    I suggest you to add an index by group in Power Query Editor and then add a custom column by IF function.

    My Sample:

    Step1:

    For reference:

    Create Row Number for Each Group in Power BI using Power Query

    Step2:

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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

     

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I suggest you to add an index by group in Power Query Editor and then add a custom column by IF function.

    My Sample:

    Step1:

    For reference:

    Create Row Number for Each Group in Power BI using Power Query

    Step2:

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

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