ratanmalko
ratanmalko

Reputation: 471

Power BI: DAX formula - build sum on group ID

I am just getting started with Power Bi and now I require some help.

I need a formula that creates a new column (called "Combined" in below example picture) that uses the following logic:

On the left side you see my current result and the desired output on the right.

example

I hope you can help me out.

Update:

To make the example a bit clearer, I combined both ParentIDs: ex2

Thank you.

Upvotes: 3

Views: 8011

Answers (1)

StelioK
StelioK

Reputation: 1781

Create two calculated columns using the following measures:

Sum Of Current = CALCULATE(SUM('Table'[Current])
                 , FILTER('Table', 'Table'[ParentID] = EARLIER('Table'[ParentID])))

Combined = IF('Table'[Sum Of Current] > 0, 'Table'[Current], 'Table'[Budget])

If you are unfamiliar with creating calculated columns just right click on any column in your table and select the 'New Column' option:

enter image description here

If you don't need both columns just use this:

Combined = IF(CALCULATE(SUM('Table'[Current])
           , FILTER('Table', 'Table'[ParentID] = EARLIER('Table'[ParentID]))) 
           > 0, 'Table'[Current], 'Table'[Budget])

Upvotes: 2

Related Questions