Forum Discussion

Christianvs's avatar
Christianvs
Helper II
3 years ago
Solved

Selecting value from different row

Hi

 

I got a table that looks like this:

 

My goal is to add a new column called NEWDIST where the DIST value is used unless there are rows with same ID. In that case it should use the DIST value of the of the ID with a blank REF. For the table here the result should look like:

I added the COUNT column to with find the duplicates in ID and tried to do an IF statement in a calculated column:

NEWDIST = IF( NOT( ISBLANK( Table[COUNT]) ),
   *FUNCTION THAT CHOOSES DIST FROM ROW 1*,
   MAX(Table[DIST]))
 
I tried using CALCULATE with a FILTER but I havent got it working. Anybody able to help me out?
If it is possible without first making the COUNT column that would be great, I just couldn't figure out how to do it without.
 
Thanks
  • Hi, 

    I am not sure if the whole possible situations are considered, but seeing the sample provided above, I tried to create a calcualted column like below.

    Please check the attached pbix file and the below picture.

     

     

     

    New DIST CC =
    IF (
        Data[Ref] = BLANK (),
        Data[DIST],
        MAXX (
            FILTER ( Data, Data[ID] = EARLIER ( Data[ID] ) && Data[Ref] = BLANK () ),
            Data[DIST]
        )
    )
    

2 Replies

  • Hi, 

    I am not sure if the whole possible situations are considered, but seeing the sample provided above, I tried to create a calcualted column like below.

    Please check the attached pbix file and the below picture.

     

     

     

    New DIST CC =
    IF (
        Data[Ref] = BLANK (),
        Data[DIST],
        MAXX (
            FILTER ( Data, Data[ID] = EARLIER ( Data[ID] ) && Data[Ref] = BLANK () ),
            Data[DIST]
        )
    )