Forum Discussion

adarshmp8998's avatar
adarshmp8998
Frequent Visitor
1 year ago
Solved

Rack Count

Hi Everyone,   I trying to find the to total rack count with the dax, can anyone help me to write a dax in power bi.   current state is 7 and the next state is 8. If so, it adds 1 to the rack cou...
  • adarshmp8998's avatar
    adarshmp8998
    1 year ago

    Greg_Deckler ,

     

    I used below method to solve it,

     

    A) created Index calculated column

    Index = RANKX('sampledf', 'sampledf'[timestamp], , ASC, DENSE)
     
    B) created NextState calculated column
    NextState =
    VAR CurrentIndex = 'sampledf'[Index]
    RETURN CALCULATE(
        MAX('sampledf'[State]),
        FILTER(
            'sampledf',
            'sampledf'[Index] = CurrentIndex + 1
        )
    )
     
    C) Written measure to calculate the Total columns
    RackCount =
    SUMX(
        'sampledf',
        IF(
            'sampledf'[State] = 7 && 'sampledf'[NextState] = 8,
            1,
            0
        )
    )