Forum Discussion

Green_G's avatar
Green_G
Frequent Visitor
2 years ago
Solved

Populate a new column with data from conditional row

Hi,

 

I am new to Power BI report building and I'm hoping you can help - I'm sure there is a simple solution but I don't know what it is!

 

I have a table like the one below and want to create an additional column called "ORIGINAL SOURCE" that shows the value in the SOURCE column for EVENT NO 1 in every row for the relevant REF VALUE.

 

REFEVENT_NOSOURCE
0011A
0012A
0013B
0014B
0015D
0021C
0022D
0023A
0024B
0025C
0026D

 

So it will look like this:

REFEVENT_NOSOURCEORIGINAL SOURCE
0011AA
0012AA
0013BA
0014BA
0015DA
0021CC
0022DC
0023AC
0024BC
0025CC
0026DC

 

I would appreciate anyone's advice on the best way to achieve this.

 

Many Thanks,

  • Green_G  you can write a measure like this

    Measure2 = 
    //what is the min event # by REF
    VAR one =
        CALCULATE (
            MIN ( 'Table 1'[EVENT_NO] ),
            ALL ( 'Table 1' ),
            VALUES ( 'Table 1'[REF] )
        ) // what is the source when event = one by ref
    VAR two =
        CALCULATE (
            MIN ( 'Table 1'[SOURCE] ),
            FILTER (
                ALL ( 'Table 1' ),
                'Table 1'[EVENT_NO] = one
                    && 'Table 1'[REF] = MAX ( 'Table 1'[REF] )
            )
        )
    RETURN
        two

     

     

1 Reply

  • smpa01's avatar
    smpa01
    Community Champion

    Green_G  you can write a measure like this

    Measure2 = 
    //what is the min event # by REF
    VAR one =
        CALCULATE (
            MIN ( 'Table 1'[EVENT_NO] ),
            ALL ( 'Table 1' ),
            VALUES ( 'Table 1'[REF] )
        ) // what is the source when event = one by ref
    VAR two =
        CALCULATE (
            MIN ( 'Table 1'[SOURCE] ),
            FILTER (
                ALL ( 'Table 1' ),
                'Table 1'[EVENT_NO] = one
                    && 'Table 1'[REF] = MAX ( 'Table 1'[REF] )
            )
        )
    RETURN
        two