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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
EFI
Helper I
Helper I

Count only last group of specifc value

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @EFI ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1687402189482.png

2. create a new coulmn in Table with below dax formula

Diff Date =
VAR tmp =
    FILTER ( 'Table', [ABS_TYPE_DESCRIPTION] = "300-maladie" )
VAR rk =
    RANKX ( tmp, [Date],, ASC )
VAR _abs = [ABS_TYPE_DESCRIPTION]
VAR val =
    IF ( _abs = "300-maladie", rk, 0 )
VAR _date = [Date]
RETURN
    _date - val

3. create a new table with below dax formula

Table 2 =
VAR tmp =
    FILTER ( 'Table', [ABS_TYPE_DESCRIPTION] = "300-maladie" )
VAR tmp1 =
    SUMMARIZE ( tmp, 'Table'[Diff Date], "Cnt", COUNT ( 'Table'[Date] ) )
RETURN
    tmp1

vbinbinyumsft_1-1687402324661.png

4. create a measure with below dax formula, and add a card visual with this measure

Latestd consecutive count =
VAR max_date =
    MAXX ( 'Table 2', [Diff Date] )
VAR val =
    CALCULATE ( MAX ( 'Table 2'[Cnt] ), 'Table 2'[Diff Date] = max_date )
RETURN
    val

vbinbinyumsft_2-1687402397567.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
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

1 REPLY 1
Anonymous
Not applicable

Hi @EFI ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1687402189482.png

2. create a new coulmn in Table with below dax formula

Diff Date =
VAR tmp =
    FILTER ( 'Table', [ABS_TYPE_DESCRIPTION] = "300-maladie" )
VAR rk =
    RANKX ( tmp, [Date],, ASC )
VAR _abs = [ABS_TYPE_DESCRIPTION]
VAR val =
    IF ( _abs = "300-maladie", rk, 0 )
VAR _date = [Date]
RETURN
    _date - val

3. create a new table with below dax formula

Table 2 =
VAR tmp =
    FILTER ( 'Table', [ABS_TYPE_DESCRIPTION] = "300-maladie" )
VAR tmp1 =
    SUMMARIZE ( tmp, 'Table'[Diff Date], "Cnt", COUNT ( 'Table'[Date] ) )
RETURN
    tmp1

vbinbinyumsft_1-1687402324661.png

4. create a measure with below dax formula, and add a card visual with this measure

Latestd consecutive count =
VAR max_date =
    MAXX ( 'Table 2', [Diff Date] )
VAR val =
    CALCULATE ( MAX ( 'Table 2'[Cnt] ), 'Table 2'[Diff Date] = max_date )
RETURN
    val

vbinbinyumsft_2-1687402397567.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors