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
DTHOMS1984
Regular Visitor

How to show the days in a row an item has appeared

HI,

 

I have a set of data that shows all data exceptions each day for the past year. I am trying to get Power Bi to show me something like the below in excel 

 

exception_nameInstrument_idprice_dateprice_pointDays in a row appeared as an exception
Primary price source not used7001164623/10/2023 00:0010AM1
Primary price source not used7001164619/10/2023 00:0010AM1
Primary price source not used7001164603/10/2023 00:0010AM1
Primary price source not used7001164629/09/2023 00:0010AM1
Primary price source not used7001164625/09/2023 00:0010AM1
Primary price source not used7001164620/09/2023 00:0010AM2
Primary price source not used7001164619/09/2023 00:0010AM1
Primary price source not used7001164613/09/2023 00:0010AM1
Primary price source not used7001164625/08/2023 00:0010AM1
Primary price source not used7001164614/08/2023 00:0010AM1
Primary price source not used7001164608/08/2023 00:0010AM1
Primary price source not used7001164601/08/2023 00:0010AM1
Primary price source not used7001164631/07/2023 00:0010AM2
Primary price source not used7001164628/07/2023 00:0010AM1
Primary price source not used7001164612/07/2023 00:0010AM1
Primary price source not used7001164630/06/2023 00:0010AM2
Primary price source not used7001164629/06/2023 00:0010AM1
Primary price source not used7001164623/06/2023 00:0010AM1
Primary price source not used7001164614/06/2023 00:0010AM2
Primary price source not used7001164613/06/2023 00:0010AM1
Primary price source not used7001164631/05/2023 00:0010AM1

 

I tried a group by but it keeps showing me the days between. 

DTHOMS1984_0-1698136681670.png

 

Does anyone have any ideas ?

 

Thanks

2 ACCEPTED SOLUTIONS

and pls try this measure

Measure 2 = 
VAR _t1 = MAX('Table'[Instrument_id])
VAR _t2 = FILTER(ALL('Table'),'Table'[Instrument_id]=_t1)
VAR _Rx = RANKX(_t2, CALCULATE(MAX('Table'[price_date])),,ASC,Dense)-1
VAR _Result =
    CALCULATE(
        MAX( 'Table'[price_date] ),
        FILTER(
            ALL( 'Table' ),
           RANKX(_t2, CALCULATE(MAX('Table'[price_date])),,ASC,Dense)= _Rx))
RETURN
    IF(
        MAX( 'Table'[price_date] ) - _Result = 1,
        ( RANKX(_t2, CALCULATE(MAX('Table'[price_date])),,ASC,Dense)-  _rx  )+ 1,
        1
    )

View solution in original post

pls try

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

View solution in original post

6 REPLIES 6
DTHOMS1984
Regular Visitor

That worked thanks very much, just out of interest see if there was ones with a date with up to 5 days in a row how would I change the dax to show the possible variables from 1,2,3,4 or 5 days in a row ?

 

pls try

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

 

Thanks @Ahmedx Should this work for multiple IDS see below ?

 

DTHOMS1984_0-1698142449172.png

 

and pls try this measure

Measure 2 = 
VAR _t1 = MAX('Table'[Instrument_id])
VAR _t2 = FILTER(ALL('Table'),'Table'[Instrument_id]=_t1)
VAR _Rx = RANKX(_t2, CALCULATE(MAX('Table'[price_date])),,ASC,Dense)-1
VAR _Result =
    CALCULATE(
        MAX( 'Table'[price_date] ),
        FILTER(
            ALL( 'Table' ),
           RANKX(_t2, CALCULATE(MAX('Table'[price_date])),,ASC,Dense)= _Rx))
RETURN
    IF(
        MAX( 'Table'[price_date] ) - _Result = 1,
        ( RANKX(_t2, CALCULATE(MAX('Table'[price_date])),,ASC,Dense)-  _rx  )+ 1,
        1
    )

yes, you check!

Measure = VAR _rx =
    RANK(DENSE, SUMMARIZE(ALLSELECTED( 'Table' ),'Table'[exception_name],'Table'[Instrument_id],'Table'[price_date]), ORDERBY( 'Table'[price_date] ), , PARTITIONBY( 'Table'[Instrument_id] ) )-1
VAR _Result =
    CALCULATE(
        MAX( 'Table'[price_date] ),
        FILTER(
            ALL( 'Table' ),
            RANK(DENSE, SUMMARIZE(ALLSELECTED( 'Table' ),'Table'[exception_name],'Table'[Instrument_id],'Table'[price_date]), ORDERBY( 'Table'[price_date] ), , PARTITIONBY( 'Table'[Instrument_id] ) )= _rx))
RETURN
    IF(
        MAX( 'Table'[price_date] ) - _Result = 1,
        ( RANK(DENSE, SUMMARIZE(ALLSELECTED( 'Table' ),'Table'[exception_name],'Table'[Instrument_id],'Table'[price_date]), ORDERBY( 'Table'[price_date] ), , PARTITIONBY( 'Table'[Instrument_id] ) )- ( _rx ) )+ 1,
        1
    )

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors