Forum Discussion
help on sameperiodelast year
Hi,
I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Volume measure: =
SUM( volume_fact[volume] )
Previous year volume measure: =
CALCULATE (
SUM ( volume_fact[volume] ),
SAMEPERIODLASTYEAR ( calendar_dimension[Date] )
)
Difference measure: =
VAR _current = [Volume measure:]
VAR _previous = [Previous year volume measure:]
VAR _condition =
_current <> BLANK ()
&& _previous <> BLANK ()
&& HASONEVALUE ( calendar_dimension[Month-Year] )
RETURN
IF ( _condition, _current - _previous )
Hi Jihwan_Kim, I used now date table field date column and I got the values, but as per SAMEPeriodelastyear dax, against Jan 2024 its not showing me Jan 2023 value.
belwo is the snip
- Jihwan_Kim2 years agoSuper User
Hi,
Please share your sample pbix file's link, and then I can try to look into it.
Thank you.
- PowerBIBeginer2 years agoHelper V
this is the main table from where i pulll volume (i.e.output column)-
in example I purposefully change names.. I cant share pbi file since in transform data more tables are connected to main table (main table my naming conv is tblname)
date table
model view
and here's the dax
- Ashish_Mathur2 years agoSuper User
Hi,
In the Calendar Table, create calculated column formulas for Year, Month name and Month number. Sort the Month name column by the Month number. To your visual, drag Year and Month name from the Calendar Table.