Michael
Michael

Reputation: 351

Add new column showing first instance. Power BI

I have a table like the following

ID   StepNumber    Total
1        1          250
1        2          10
1        3          5
2        1          20 
2        2          30
3        1          100

I wish to add a new column which returns the 'Total' value for each ID on StepNumber 1.

So the expected output is:

ID   StepNumber    Total     NewColumn
1        1          250        250
1        2          10         250
1        3          5          250
2        1          20         20
2        2          30         20
3        1          100        100

I'm totally new to DAX and any help is appreciated.

Upvotes: 1

Views: 39

Answers (1)

mkRabbani
mkRabbani

Reputation: 16908

Create a Measure as below-

grand_total = 
CALCULATE(
    SUM(your_table_name[Total]),
    FILTER(
        ALLEXCEPT(your_table_name,your_table_name[ID]),
        your_table_name[StepNumber] = 1
    )
)

Output-

enter image description here

Upvotes: 1

Related Questions