Forum Discussion

Benrod's avatar
Benrod
New Member
2 years ago
Solved

Add values when other column is a duplicate value

Hello all,

 

I'm facing an issue in Power BI Desktop with the following:

I need my 'object' column to be PK. However there can be more than one amount registered on this object. Dataset has the following structure;

 

To make this object column PK I want to add the amount numbers to have it structured as the following:

 

please keep in note that object column is a lookupvalue from a measured column and therefore cant be seen in Query Editor

 

Can someone help me solve this issue?

 

thank you!

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Benrod ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a table and a calculated column.

    Table 2 = VALUES('Table'[object])
    amount = CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[object]=EARLIER('Table 2'[object])))

    (3) Then the result is as follows.

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

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

2 Replies

  • please keep in note that object column is a lookupvalue from a measured column 

    Can you explain this a bit further please?

     

    Usually you would normalize your data into the object dimension table and the Amounts fact table.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Benrod ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a table and a calculated column.

    Table 2 = VALUES('Table'[object])
    amount = CALCULATE(SUM('Table'[amount]),FILTER('Table','Table'[object]=EARLIER('Table 2'[object])))

    (3) Then the result is as follows.

     

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

     

    Best Regards,

    Neeko Tang

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