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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
pankajj
Helper III
Helper III

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.

 

Screenshot.png

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

2 ACCEPTED SOLUTIONS

@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



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

@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))

View solution in original post

7 REPLIES 7
Fowmy
Super User
Super User

@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

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy 

Thanks a ton for your quick reply.

Using Sum in the measure gives me following Result:

Screenshot1.png

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 
Can you share sample data from the date and the fact table, is cumulative max days a measure?

________________________

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

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@Fowmy

I have uploaded PBIX & Excel sample data file for reference

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

Thanks once again for your help.

@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



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

@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))

@Fowmy 

 

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

 

I am looking for a result similar to :

 

Screenshot 2020-09-21 130825.png

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.