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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Syndicate_Admin
Administrator
Administrator

Create a YTD and YTD-1 table

Estimates I have a dynamic Calendar table, which depends on a variable date that comes from another table, I need your support please to create an automatic YTD table, whose characteristics vary according to what varies the calendar table being the ytd the corresponding period from January to the last date of the calendar and the ytd-1, it is the same period but from the previous year, as shown in the image.

Thank you in advance for your support

I attach the link to the dynamic calendar table in pbix.

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

ytd1.jpg

1 ACCEPTED SOLUTION
vojtechsima
Super User
Super User

Hi, @Syndicate_Admin , @jminanoc
see my solution below:

NewTable = 
var YTD_Dates = DATESYTD(Calendario[C_Fecha])
var YTD_Min = MINX(YTD_Dates, Calendario[C_Fecha])
var YTD_Max = MAXX(YTD_Dates, Calendario[C_Fecha])
var PreviousYTD = SAMEPERIODLASTYEAR(YTD_Dates)
var PreviousYTDMax = MAXX(PreviousYTD,Calendario[C_Fecha])
var PreviousYTDMin = MINX(PreviousYTD,Calendario[C_Fecha])

return CALCULATETABLE(Calendario, Calendario[C_Fecha] >= YTD_Min && Calendario[C_Fecha] <= YTD_Max|| Calendario[C_Fecha] >= PreviousYTDMin && Calendario[C_Fecha] <= PreviousYTDMax)

vojtechsima_0-1635884141690.png

 



View solution in original post

3 REPLIES 3
vojtechsima
Super User
Super User

Hi, @Syndicate_Admin , @jminanoc
see my solution below:

NewTable = 
var YTD_Dates = DATESYTD(Calendario[C_Fecha])
var YTD_Min = MINX(YTD_Dates, Calendario[C_Fecha])
var YTD_Max = MAXX(YTD_Dates, Calendario[C_Fecha])
var PreviousYTD = SAMEPERIODLASTYEAR(YTD_Dates)
var PreviousYTDMax = MAXX(PreviousYTD,Calendario[C_Fecha])
var PreviousYTDMin = MINX(PreviousYTD,Calendario[C_Fecha])

return CALCULATETABLE(Calendario, Calendario[C_Fecha] >= YTD_Min && Calendario[C_Fecha] <= YTD_Max|| Calendario[C_Fecha] >= PreviousYTDMin && Calendario[C_Fecha] <= PreviousYTDMax)

vojtechsima_0-1635884141690.png

 



Thank you very much for your prompt response and accurate response, it is very similar to what I needed.

Hi, @Syndicate_Admin , @jminanoc 
Glad to hear that, if you could Kudo and mark my original post as the solution.

 

Thank you

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.