Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I've tried searching, but not seen this anywhere...
I'm building a report, and want to keep the date slicer small and simple, so I used a relative date slicer, which also updates to the current date, so that was nice. But when I then add a last year and last week measure, the result is that it will go back in time and show me the current day result. I found this to be linked to the slicer using date hierarchy or not.
Without hierarchy:
It seems the calculation goes back in time as requested, then shows the number for the selected date.
With a hierarchy in the slicer:
This is the result I was expecting, no matter if the hierarchy was added to the slicer.
Is there anyway to use the relative time slicer and still get the result as with the hierarchy?
Thanks
Øystein
Solved! Go to Solution.
Hi @Anonymous ,
If your date column is not continuously, not recommend to use Time-intelligence function like dateadd(), sameperiodlastyear() etc.
Based on your description, you can create a control measure like this, put it in the visual filter and set its value as 1:
Control =
VAR _max =
CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
VAR _min =
CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
RETURN
IF (
SELECTEDVALUE ( 'Table'[Date] ) >= _min
&& SELECTEDVALUE ( 'Table'[Date] ) <= _max,
1,
0
)
Then you can create measures like this:
now = SUM('Table'[value])
prev =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Date]
>= MIN ( 'Table'[Date] ) - 7
&& 'Table'[Date] <= MIN ( 'Table'[Date] )
)
)
ly =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
YEAR ( 'Table'[Date] )
= YEAR ( MIN ( 'Table'[Date] ) ) - 1
&& QUARTER ( 'Table'[Date] ) = QUARTER ( MIN ( 'Table'[Date] ) )
&& MONTH ( 'Table'[Date] ) = MONTH ( MIN ( 'Table'[Date] ) )
&& DAY ( 'Table'[Date] ) = DAY ( MIN ( 'Table'[Date] ) )
)
)
Attached a sample file in the below ,hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for your reply. I'll check it out.
Øystein
Hi,
sorry, did not add the calculations:
Hi @Anonymous ,
If your date column is not continuously, not recommend to use Time-intelligence function like dateadd(), sameperiodlastyear() etc.
Based on your description, you can create a control measure like this, put it in the visual filter and set its value as 1:
Control =
VAR _max =
CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
VAR _min =
CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table' ) )
RETURN
IF (
SELECTEDVALUE ( 'Table'[Date] ) >= _min
&& SELECTEDVALUE ( 'Table'[Date] ) <= _max,
1,
0
)
Then you can create measures like this:
now = SUM('Table'[value])
prev =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
'Table'[Date]
>= MIN ( 'Table'[Date] ) - 7
&& 'Table'[Date] <= MIN ( 'Table'[Date] )
)
)
ly =
CALCULATE (
SUM ( 'Table'[value] ),
FILTER (
ALL ( 'Table' ),
YEAR ( 'Table'[Date] )
= YEAR ( MIN ( 'Table'[Date] ) ) - 1
&& QUARTER ( 'Table'[Date] ) = QUARTER ( MIN ( 'Table'[Date] ) )
&& MONTH ( 'Table'[Date] ) = MONTH ( MIN ( 'Table'[Date] ) )
&& DAY ( 'Table'[Date] ) = DAY ( MIN ( 'Table'[Date] ) )
)
)
Attached a sample file in the below ,hopes to help you.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , how you created these measures. Please share formula.
refer these , if they can help
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
User | Count |
---|---|
75 | |
74 | |
44 | |
31 | |
27 |
User | Count |
---|---|
99 | |
89 | |
52 | |
48 | |
46 |