Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

conditional counter

Hello everybody,

I want to know if it's possible to create a column starting at 0 and increasing by one unit every time the value one occurs in another column. This is what I want to obtain :

 

 

I'd like to have an answer using DAX and not Power Query because nb is already a column I created using some functions in DAX (LOOKUPVALUE for example).

  • Anonymous 

     

    So you can sum NB for all indices before current row..right?

     

    =
    CALCULATE (
        SUM ( table1[Nb] ),
        FILTER ( Table1, [Index] <= EARLIER ( [Index] ) )
    )
    

2 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Community Champion

    Anonymous 

     

    So you can sum NB for all indices before current row..right?

     

    =
    CALCULATE (
        SUM ( table1[Nb] ),
        FILTER ( Table1, [Index] <= EARLIER ( [Index] ) )
    )
    
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks ! That was exactly what I wanted, looks really easy ahah but I'm just starting to dive into Power Bi !
      This query suceed on the little table I gave you but I'm working with a table of 50 000 rows and I'm facing a memory problem.