Forum Discussion
Peter_23
Advocate V
2 years agoComparing two periods
Hi Power Bi users, I would like a measure to compare two periods at least, e.g. Feb23 vs Feb22, Apr23 vs Apr22, but sometimes it could be Feb23 vs Feb20, in case there is not data in 22,21.. so I...
danextian
Super User
2 years agoHi Peter_23 ,
If you want it hardcoded, you can try something like this:
January 2023 =
CALCULATE (
[Total Revenue],
FILTER (
ALL ( Dates ),
MONTH ( Dates[Date] ) = 1
&& YEAR ( Dates[Date] ) = 2023
)
)
This approach is very manual and require a lot of measures for periods that you want to compare.
Alternatively, I would use a two-slicer approach - for periods being compared. The second slicer is coming from a disconnected table which doesn't have relationship to your fact table. Either approach will require a separate dates table.
In the sample pbix, there are only two years of data but should work for more years.