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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.