Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I've a matrix visual and data looks like as in below table. I want to find previous years same month value. I don't have date column in the the table so I can't use sameperiodlastyear. Please suggest any workaround to find the exact value
Hi,
You may not have a Date column but if you have a year and Month number column, then you should be able to create a date column via a calculated column formula using the DATE() function.
@MFT , Make sure you have a separate year month column with key year month in that table(say date) and your table (say Table) and join them on key
then have measure like
This Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && Date[Month]=max(Date[Month])))
Last year same Month = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && Date[Month]=max(Period[Month])))
you can also create a date using
date = Date([Year], [Month],1)
Not you can use date table and time intellignece
examples
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))
Previous year Month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth(dateadd('Date'[Date],-11,MONTH)))
last year MTD (complete) Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(ENDOFMONTH(dateadd('Date'[Date],-12,MONTH))))
Month behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Month))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Time Intelligence, Part of learn Power BI https://youtu.be/cN8AO3_vmlY?t=27510
Time Intelligence, DATESMTD, DATESQTD, DATESYTD, Week On Week, Week Till Date, Custom Period on Period,
Custom Period till date: https://youtu.be/aU2aKbnHuWs&t=145s
Hi @amitchandak
Data is little tricky, let say current year is
Year 2022, Month 1 to 12,
Year 2021 Months 1 to 24
Year 2020 Months 1 to 36
Year 2019 Month 1 to 48
and so on. Please help me to make the key column or suggest how to find previous year same month value.
thanks in advance.
FT