Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Data for example:
Month | Jan | YTD | Feb | YTD | Avg | Avg | ||||
Place | 2019 | 2020 | 2019 | 2020 | 2019 | 2020 | 2019 | 2020 | 2019 | 2020 |
x | 500000 | 450000 | ? | ? | 300000 | 470000 | ? | ? | ? | ? |
y | 100000 | 560000 | ? | ? | 600000 | 950000 | ? | ? | ? | ? |
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.
Solved! Go to Solution.
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.
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.
@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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |