cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
victorPerez Frequent Visitor
Frequent Visitor

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 :

 

Captureblog.PNG

 

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).

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: conditional counter

@victorPerez 

 

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

 

=
CALCULATE (
    SUM ( table1[Nb] ),
    FILTER ( Table1, [Index] <= EARLIER ( [Index] ) )
)
2 REPLIES 2
Highlighted
Super User
Super User

Re: conditional counter

@victorPerez 

 

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

 

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

Re: conditional counter

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.