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