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
Anonymous
Not applicable

DatesYTD Fuction based on Year and Month Slicer - Not working as expected

Hi, I am using the below DAX query for DatesYTD calculation. 

 

In the last calcuate function, for which ever month the employee count is 0, then my DatesYTD function too gives 0 only.

 

Example:-

January - 4         ----- DatesYTD is 4

February - 5       ----- DatesYTD is 9

March - Blank()           ----- DatesYTD coming Blank()      -- This is worng

April - 6              ----- DatesYTD is 15 

Ramees_123_0-1621495299965.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

I think you want to get a running total by Month. So March = blank is wrong, you want March = 9.

Due to I don't know your data model, I build a sample to have a test.

My Sample:

1.png

I build a unrelated DimDate table by dax.

 

DateDim = ADDCOLUMNS(CALENDAR(DATE(2021,01,01),TODAY()),"Year",YEAR([Date]),"MonthNUM",MONTH([Date]),"MonthName",FORMAT([Date],"MMMM"))

 

Measure:

 

DateYTD = 
VAR _MaxDate = MAX(DateDim[Date])
Return
CALCULATE(COUNT('1st Party& 3rd Party'[EmployeeID]),FILTER(ALL('1st Party& 3rd Party'),'1st Party& 3rd Party'[Date]<=_MaxDate))

 

Result:

2.png

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous 

I think you want to get a running total by Month. So March = blank is wrong, you want March = 9.

Due to I don't know your data model, I build a sample to have a test.

My Sample:

1.png

I build a unrelated DimDate table by dax.

 

DateDim = ADDCOLUMNS(CALENDAR(DATE(2021,01,01),TODAY()),"Year",YEAR([Date]),"MonthNUM",MONTH([Date]),"MonthName",FORMAT([Date],"MMMM"))

 

Measure:

 

DateYTD = 
VAR _MaxDate = MAX(DateDim[Date])
Return
CALCULATE(COUNT('1st Party& 3rd Party'[EmployeeID]),FILTER(ALL('1st Party& 3rd Party'),'1st Party& 3rd Party'[Date]<=_MaxDate))

 

Result:

2.png

 

Best Regards,

Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. 

amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

You have to make sure DateDim is marked as a date table, You have to use month year from the date table

 

There are 5 reason -Why Time Intelligence Fails - Power bi 5 Savior Steps for TI: https://youtu.be/OBf0rjpp5Hw

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

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!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.