Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

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

 

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

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

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

 

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

Regards
Zubair

Please try my custom visuals
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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors