Forum Discussion

pankajj's avatar
pankajj
Helper III
5 years ago
Solved

Cumulative Max Days

Greetings!

I am having trouble getting Cumulative Max days.

To calculate the same I have used following measure:

 
Cumulative Max Days = CALCULATE(MAX(SN[DaysTillToday]), FILTER(ALL ('Dates'), 'Dates'[Date] <= MAX('Dates'[Date])))

This gives me Max days but not the cumulative result.

 

I have uploaded PBIX & Excel sample data file for reference

https://drive.google.com/drive/folders/1m3uGRUPN28hqKPab2oYSmzO91z9t0BT3?usp=sharing 

 

Looking forward for a quick guidance please.

Thanks & best regards,

PG

  • Fowmy's avatar
    Fowmy
    5 years ago

    @pankajj

    I haven't exactly got what you're trying to do, but this measure will give you what you need

    Cumulative Max Days = 
    
    CALCULATE(
        COUNT(Dates[Date]),
        FILTER(
            ALLSELECTED(Dates),
            Dates[Date] < MAX(Dates[Date] )
        )
    )

    Fowmy_0-1600717034861.png

    ________________________

    If my answer was helpful, consider Accepting it as the solution to help other members find it

    Click the Thumbs-Up icon if you like this answer 🙂

    Youtube Linkedin



  • @Fowmy

    Thanks a ton for your kind help. It worked perfectly with the sample file i shared.

    In the meantime i created following measures to get the desired result in my existing data.

    Open =
    Was
    (dates[Date])
    RETURN
    calculate(
    CALCULATE(count(SN[ID])+0,
    SN,
    SN[Created]<=d
    ),
    crossfilter(SN[Created],Dates[Date],None)
    )

    OLDEST_Open_Date =
    Was
    d - MAX (Dates[Date])
    RETURN
    CALCULATE(
    FORMAT(CALCULATE(MIN(SN[Created]),
    SN,
    SN[Created]<=d),
    "Short Date"
    ),
    CROSSFILTER(SN[Created],Dates[Date],None)
    )


    Cumulative_Max_Days =
    Was
    d - Max (Dates[Date])
    RETURN
    CALCULATE(if([Open]>0,DATEDIFF(SN[OLDEST_Open_Date],d,Day),0))

7 Replies

  • pankajj 

    For Cumulative Total, you need to use the SUM

    Cumulative Max Days = 
    CALCULATE(
        SUM(SN[DaysTillToday]), 
        FILTER(ALL ('Dates'), 'Dates'[Date] <= MAX('Dates'[Date]))
    )

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

    • pankajj's avatar
      pankajj
      Helper III

      Fowmy 

      Thanks a ton for your quick reply.

      Using Sum in the measure gives me following Result:

      However I am looking for a result which should be something like:

       

      DateCumulative Max Days
      September21 202013
      September20 202012
      September19 202011
      September18 202010
      September17 20209
      September16 20208
      September15 20207
      September14 20206
      September13 20205
      September12 20204
      September11 20203
      September10 20202
      September09 20201
      September08 20200

       

      • pankajj's avatar
        pankajj
        Helper III

        Fowmy 

         

        Sorry for the error, Html format has changed the table content.

         

        I am looking for a result similar to :