Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Good
I have a Sales table, with the units sold of a product. I have the years 2022 and 2023. The client can filter for a specific period of 2023. For example 25/01/2023 to 02/02/2023. As it appears in the filter:
Filtro fechaDate filter
I would like a table to appear with the month, day, you sold current year and you sold previous year.
The problem is that when I add the column UdsSoldPreviousPeriod, I get the following error:
It's like it won't let me calculate the units of the previous year by applying the filter segment of only the period 25/01/2023 - 02/02/2023. The measure I use to calculate the units of the previous year is as follows:
UdsVendidasPeriodoAnteriorNoWeb =
var minfecha = MIN(Fecha[Fecha])
var minfechaN1 = DATE(YEAR(minfecha)-1,MONTH(minfecha),DAY(minfecha))
var maxfecha = MAX(Fecha[Fecha])
var maxfechaN1 = DATE(YEAR(maxfecha)-1,MONTH(maxfecha),DAY(maxfecha))
var calc = CALCULATE(SUM(Ventas[cantidad]), ALLCROSSFILTERED(Fecha), Ventas[fecha]>=minfechaN1 && Ventas[fecha]<=maxfechaN1)
return calc
How could I calculate it and show it in the table?
Thank you
Thank you so much. I have tried the SAMEPERIODLASTYEAR as you told me and it works perfectly.
Thank you!
@Syndicate_Admin , Make sure, you have date table joined with your table and then create a measure like
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.