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
shairado
Frequent Visitor

Calculate Cumulative YTD MEDIAN Duration having Month with Empty Values

Hi,

 

I am trying to CALCULATE a CUMULATIVE YTD MEDIAN Duration of projects length.

Some of my months do not have any data in them, as none of the projects were completed on May-2022.

 

The left table is the data of Projects (no project completed on May-2022), and the right table shows my DAX Measure.

As you can see, there is no Cumulative YTD MEDIAN value for May-2022.

 

Tables.PNG

 

 

 

 

 

 

 

 

 

This ends up having a Cumulative Line chart, which is missing May-2022.

 

 

chart.PNG

 

 

 

 

 

 

MY DAX Measure

 

Cumulative YTD Median Duration  = 
VAR __MaxCompletedDate = MAX( 'TPL'[Project Close Date] )
RETURN
CALCULATE( 
     MEDIAN( TPL[Proj Duration Close] ) ,
     FILTER( ALLSELECTED( 'Date' ),
         'Date'[Date] <= __MaxCompletedDate 
         && YEAR( 'Date'[Date] ) = 2022
         )
     )

 

 

How can I modify my DAX to show May-2022 result?

It should be the same value as April-2022, as the Cumulative YTD MEDIAN has not changed.

 

Thanks,

Shai

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@shairado , Make sure the axis is using a column from the date table.

 

If needed try this measure

 

Cumulative YTD Median Duration =
VAR __MaxCompletedDate = MAX( 'TPL'[Project Close Date] )
RETURN
CALCULATE(
MEDIAN( TPL[Proj Duration Close] ) ,
datesytd('Date'[Date] )
)

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@shairado , Make sure the axis is using a column from the date table.

 

If needed try this measure

 

Cumulative YTD Median Duration =
VAR __MaxCompletedDate = MAX( 'TPL'[Project Close Date] )
RETURN
CALCULATE(
MEDIAN( TPL[Proj Duration Close] ) ,
datesytd('Date'[Date] )
)

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak  the DATESYTD function worked 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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