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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
damj
Frequent Visitor

consecutive day

Hi.

Trying to create a column that counts consecutive days based on "Eventkode" sorted in "Litra" like the illustration shown below.

Hope someone can help.

Udklip.PNG

Thanks in advance.

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @damj 

Create calculated columns

clc1 = CALCULATE(DISTINCTCOUNT('Table'[date]),FILTER(ALLEXCEPT('Table','Table'[litra]),[date]<=EARLIER('Table'[date])))

earlier day = CALCULATE(MAX('Table'[date]),FILTER(ALLEXCEPT('Table','Table'[litra]),'Table'[date]=EARLIER('Table'[date])-1))

clc 2 = IF([earlier day]=BLANK(),1,[clc1])
Capture5.JPG
 
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @damj 

Create calculated columns

clc1 = CALCULATE(DISTINCTCOUNT('Table'[date]),FILTER(ALLEXCEPT('Table','Table'[litra]),[date]<=EARLIER('Table'[date])))

earlier day = CALCULATE(MAX('Table'[date]),FILTER(ALLEXCEPT('Table','Table'[litra]),'Table'[date]=EARLIER('Table'[date])-1))

clc 2 = IF([earlier day]=BLANK(),1,[clc1])
Capture5.JPG
 
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Mariusz
Community Champion
Community Champion

Hi @damj 

 

Try this column.

Column = 
VAR _tbl = CALCULATETABLE( VALUES( 'Table'[Date] ), ALLEXCEPT(  'Table', 'Table'[Litra] ) )
RETURN 
RANKX( _tbl, CALCULATE( MAX( 'Table'[Date] ) ),,DESC )

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

damj
Frequent Visitor

Hi Mariusz.

Tried to implement the code, but it didn't have the desired effect.

I need "Eventcode" to count up for each day it triggers when consecutive, and start from 1 when not. Sorted in the different "Litra" = (Machinenr).

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.