Forum Discussion
help on sameperiodelast year
Hi All,
I've one Dax which gives me no of volume and have derived with help of Dax. Now problem is, I've 2024 year-month column, i also derived last year 2023 year-month column. infact I've volume for current year and 2023 as well by creating 2 dax.. but dont know how to get that values against every month.. for e.g. below is the scenario.
Now I dont understand how I can get volume 2023 values next to 150, 250 & 350 i.e. 100,200,300 and then I want new colume after volume 2023 "Difference" so minus of 150-100 value need in that column..
| current year | previous year | volume 2024 | volume 2023 |
| Jan-2023 | - | 100 |
| Feb-2023 | - | 200 | |
| Mar-2023 | - | 300 | |
| Jan-2024 | Jan-2023 | 150 | - |
| Feb-2024 | Feb-2023 | 250 | - |
| Mar-2024 | Mar-2023 | 350 | - |
Can any one please guide here..
10 Replies
- Jihwan_KimSuper User
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 )- PowerBIBeginerHelper V
Thank you so much for your reply and valuable time share for me. Let me try this and will update you on the same..
- PowerBIBeginerHelper V
Hi Jihwan_Kim.. Appriciate your effort for understanding mu issue exactly well and try to plot across very nicely. I would like to hightlight here something that, Volume Measure you've taken simply sum of one column, even I do that but using one filter condition in that.
for e.g.
volume = calculate(sum(tblname[volume]), tblname[onecolumn]="VC")
and hence I designed Previous year Volume like below but I got blanks..
Previuos year volume = CALCULATE( SUM(tblname[Volume]), tblname[onecolumn]="VC", SAMEPERIODLASTYEAR(tblname[date]))- Ashish_MathurSuper User
Hi,
You have not created a calendar Table, as suggested by Jihwan. Study his solution carefully.
- PowerBIBeginerHelper V
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_KimSuper User
Hi,
Please share your sample pbix file's link, and then I can try to look into it.
Thank you.