Forum Discussion

jc173's avatar
jc173
Frequent Visitor
2 years ago
Solved

Increment value with condition

Hi guys i have this situation: 1 0 1 1 1 0 1 I would like to get this, 1 1 0 0 1 2 1 2 1 2 0 0 1 3 1 3 Every time i have a 0 value i nee...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi jc173 ,

    Based on your questions, here are my answers.

    Firstly, create a table as you mentioned.

    Then go to the Power Query and select the Index Column.

    Enter the appropriate DAX code to get the results you need.

     

    Column = 
    IF (
        'Table'[Column1] <> 0,
        RANKX ( FILTER ( 'Table', 'Table'[Column1] = 0 ), 'Table'[Index],,ASC ),
        0
    )

     

     

     

    Best Regards

    Yilong Zhou

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