Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello.
I have an issue regarding YTD - YTD last year.
Currently I am using
TOTALYTD and it works fine for this year, for next measure for last year using SAMEPERIODLASTYEAR counts the whole year which is not what i want.
The issue is that I am only interested in to compare the the same period meaning 2023-01-06 to 2022-01-06.
I am thinking of creating a VAR lastyear as = date(year(today()) -1, ) or something similar to use it as a filter.
I am using a matrix for the visualisation, and i will have different measurements comparing the same YTD - YTD last year, so having a filter on a visual will not work for me.
Any suggestions are welcome
Solved! Go to Solution.
What I did to solve this issue:
Created a column:
Var maxdate =max(table[datecolumn])
Datediff(table[datecolumn]),maxdate,day)
Made a new measure:
Calculate(countx(table,table[column]), filter1,filter2,filter3,and last filter was the new created colmn>=365.
My data imported only is from 2022 onwards, if i had multilple years i just add another filter with <=730.
What I did to solve this issue:
Created a column:
Var maxdate =max(table[datecolumn])
Datediff(table[datecolumn]),maxdate,day)
Made a new measure:
Calculate(countx(table,table[column]), filter1,filter2,filter3,and last filter was the new created colmn>=365.
My data imported only is from 2022 onwards, if i had multilple years i just add another filter with <=730.
A quick way of doing this is having two filters for the Date. Power BI doesn't have one which does this, so using one twice solves the problem.
User | Count |
---|---|
84 | |
80 | |
70 | |
47 | |
43 |
User | Count |
---|---|
109 | |
54 | |
50 | |
40 | |
40 |