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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
romilv1
Helper I
Helper I

YTD calculations using Month-Year

Hello!

 

I have a fitler that uses Month-Year in below format. We have month-year column in dim.date table

 

romilv1_0-1710361717969.png

 

I want to use YTD calculations but that doens't work as it needs date column where Month-Year column is a text column. To overcome this situation I have created calendar table based on advice posted here: https://community.fabric.microsoft.com/t5/Desktop/Calculate-YTD-with-Month-Year/td-p/3171222

I then join the Calendar.Date with the dimDate.Date column (Many to One and Single) and was able to use the Calendar Date as the argument in TotalYTD calcuations using formula as below;

 

TOTALYTD(SUM(TableName[Amount])+0.00, 'Calendar'[Date])
Using above formula doesn't give me YTD values but instead give me selected month value example for Dec '23 it should be total value of Jan '23 - Dec '23 but it shows Dec'23 values.
 
I have also used below formula 

Total = sum(TableName[Amount])

Total YTD = calculate([Total],datesytd('Calendar'[Date],"31/12"))

 

Second formula also generates the same result and doesn't generate YTD. How do I make YTD work if Month-Year is used in filter?

 

Existing table (refer column 1 & 3)

 

romilv1_1-1710362102248.png

TestYTDActuals should show below data

 

361,494

0

0

0

0

152,182

 

Instead it shows the data exactly as column 3 which is monthly data.

1 ACCEPTED SOLUTION

Hi @romilv1 ,

You can click the small arrow next to the date field and select hierarchy. But when you create a relationship (many-to-one or one-to-many) between tables with Date , only the dates on one side show the date hierarchy. For more information, please refer to the link: Solved: Date hierarchy not available - Microsoft Fabric Community.

vkaiyuemsft_0-1711000442706.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

5 REPLIES 5
v-kaiyue-msft
Community Support
Community Support

Hi @romilv1 ,

1. Please try modifying the slicer to use the date column. Consider using the "Date" column from the calendar table instead of using the "Month-Year" text column for the slicer. This slicer can be formatted to display dates in month-year format while still retaining their Date data type. This change ensures that filter context is correctly applied to time intelligence functions.

 

2. Please try to use FILTER function instead of datesytd function, such as

Measure =
CALCULATE(SUM(financials[Sales]),FILTER(ALL('financials'),'financials'[Date] <= MAX('financials'[Date]) && 'financials'[Date] >= DATE(YEAR(MAX ('financials'[Date])),1,1)))

vkaiyuemsft_0-1710926130695.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

Thanks @v-kaiyue-msft  This is similar to the solution what I was looking for. How can we format the slicer to display dates in Month Year format while retaining "Date" date type?

Hi @romilv1 ,

You can click the small arrow next to the date field and select hierarchy. But when you create a relationship (many-to-one or one-to-many) between tables with Date , only the dates on one side show the date hierarchy. For more information, please refer to the link: Solved: Date hierarchy not available - Microsoft Fabric Community.

vkaiyuemsft_0-1711000442706.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

romilv1
Helper I
Helper I

Hello! @Ashish_Mathur 

I can't share pbi file as it has confidential data and it is connect to Azure Syanpse which would mean it won't open unless it has access.. If there is any other way to share let me know.

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.