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

How to Calculate YTD of every month

Data for example:

MonthJan YTD Feb YTD AvgAvg
Place2019202020192020201920202019202020192020
x500000450000??300000470000????
y100000560000??600000950000????

 

Now I want to calculate YTD for these values in Power Bi.

And I also want to calculate the average of the months.

Require help in this. Thanks in advance.

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create a calendar table first of all, create relationship with your fact table on date field, then create measures like DAX below in your fact table.

 

 

Calculated table:

Calendar=CALENDARAUTO()



Measure:



YTD for CY = TOTALYTD(SUM(Table1[Sales]),'Calendar'[Date])



YTD for PY = CALCULATE(SUM(Table1[Sales]),SAMEPERIODLASTYEAR('Calendar'[Date]))



Ave YTD for CY= AVERAGEX(Table1, [YTD for CY] )



Ave YTD for PY= AVERAGEX(Table1, [YTD for PY] )

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

You may create a calendar table first of all, create relationship with your fact table on date field, then create measures like DAX below in your fact table.

 

 

Calculated table:

Calendar=CALENDARAUTO()



Measure:



YTD for CY = TOTALYTD(SUM(Table1[Sales]),'Calendar'[Date])



YTD for PY = CALCULATE(SUM(Table1[Sales]),SAMEPERIODLASTYEAR('Calendar'[Date]))



Ave YTD for CY= AVERAGEX(Table1, [YTD for CY] )



Ave YTD for PY= AVERAGEX(Table1, [YTD for PY] )

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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 ,

Are you lloking for format or YTD.

For YTD use time intelligence and date calendar

example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184

Time intelligence: https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-1-Time-Intelligence-in/ba-p/922885

Appreciate your Kudos.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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