Forum Discussion
Anonymous
6 years agoNot applicable
Slicer with if statement
I have a slicer that contains multiple quarters. I will like to have a formula where if i click on Q1 2020, the formula will sum up the revenue of the prior yr revenue (ie Q1 2019). One of the car...
- 6 years ago
Hi Anonymous ,
We can use two ways to meet your requirement.
First way,
- We need to create a table that contains date and quarter.
Dates = ADDCOLUMNS ( CALENDAR ( "2018/1/1", "2020/12/31" ), "Year Quarter Number", [date] * 100 + QUARTER ( [date] ))- Then we can create two measures to get the result,
current revenue = var current__ = SELECTEDVALUE(Dates[Year Quarter Number]) return CALCULATE(SUM('Table'[revenue]),'Table'[Year Quarter Number]=current__)LQ revenue = var current__ = SELECTEDVALUE(Dates[Year Quarter Number]) return CALCULATE(SUM('Table'[revenue]),'Table'[Year Quarter Number]=current__-100)The slicer uses Dates[Year Quarter Number].
Second way,
- We need to create a Dates table like first way.
- We can use the SAMPERIODLASTYEAR function to create the last year quarter measure.
Measure = CALCULATE(SUM('Table'[revenue]),SAMEPERIODLASTYEAR(Dates[Date]))- At last we need to create a relationship between two tables based on date. Then we can get the result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?
BTW, the first way doesn’t need to create a relationship, and pbix file as attached.
Best regards,
parry2k
6 years agoSuper User
Anonymous there are many solutions/posts on time intelligence, the key here is to add calendar dimension in your model and mark it as date table and then use time intelligence functions for the measure.