Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

How to tag first occurrence with a filter

Hello, I want to flag the first occurrence of accounts based on a date, with a filter (it should only consider if ACTIVE=yes), and if there are duplicates i need to choose only one of them (randomly/...
  • Dangar332's avatar
    Dangar332
    2 years ago

    hi, Anonymous 

     

    Earlier() function use when you have two or more row context and you want to use outer row context value refrence as current.

     

    in our case we use code in calculated column so it give first row context and  maxx it give second row context and we want to use refrence of  Account column .

     

    when we move row by row in our table first row refer account and we move second row it still refer and we compare it with current acoount column value

    in some case it syntax sugar of variable
    below same code for same result

    Column 2 = 
    var a1= 'Table (2)'[Account]
    var a = 
        MAXX(
          FILTER(
             'Table (2)',
             'Table (2)'[Account]=a1 && 
             'Table (2)'[Active]="yes"),'Table (2)'[Index]
        )
    return
    IF('Table (2)'[Index]=a,1,0)

     

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