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
i have this dax function to calculate page views same period from last year
Hi @Anonymous ,
I agree with @Anonymous, it is good practice to organize your data model with a dedicated date table and create a relationship with your other table.
Then you use a CALCULATE() function with a SAMEPERIODLASTYEAR() function
It would look something like that
Measure from last year = CALCULATE ( [MyMeasure], SAMEPERIODLASTYEAR ( calendarTbl[Date] ) )
For more info on SAMEPERIODLASTYEAR() check this page https://docs.microsoft.com/en-us/dax/sameperiodlastyear-function-dax
Let us know if you need more help in refining your model
this does not work in my situation. actually i've already tried this function. that's why i have to use a long dax code. i basically defind these variables and it works 80%. it's just when i select the date slicer, the goal did not change as expected. it became blank. and when i change another slicer, it works. i would love to go with my current solution because it's so close.
thank you so much!
Hi @Anonymous
Can you provide some sample data?
this is how it looks like: when i did not select anything in 'View Date', it shows 82679 in indicator which is all data from 2018 and 19 and (31300 which is 2018 data).
but when i select 2019, the perfect situation is indicator 51379 and goal should be 31300, but it shows blank. i really think it's very close to what i want. may just be some slight change. i created two measures for indicator and goal, and they are in my first threshold.
Hi @Anonymous
See the illustration below if that can be of help
If that still doesn't work for you, you could send me the file with some sample data at david@fumastra.com
I'd start by getting a dedicated date table and relate that your fact table. Then you can leverage the time intelligence functions, or at least make writing the dax easier and increase performance.
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.