Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello experts,
I'd like to know how to create a date segmentation that can handle different visual criteria.
For example, suppose I have a dashboard, which consists of 4 visuals and a date segmentation. If I select 30-APR-2020, the 2 visuals will display the data for the last 2 weeks of the selected date (16-APR to 30-APR) while the rest show the data on that date (30-APR).
Thanks a lot.
In
Solved! Go to Solution.
Hi, @kitti
Based on your description, I created data to reproduce your scenario.
Table:
Calendar(a calculated table):
Calendar = CALENDARAUTO()
You may create two measures as below. 'Visual control 1' is to display the data for the last 2 weeks of the selected date. 'Visual control 2' is to show the data on the selected date.
Visual control 1 =
var _selectedate = SELECTEDVALUE('Calendar'[Date])
var _date = SELECTEDVALUE('Table'[Date])
var _datediff = DATEDIFF(_date,_selectedate,DAY)
return
IF(
_datediff<=14&&_datediff>=0,
1,0
)
Visual control 2 =
var _selecteddate = SELECTEDVALUE('Calendar'[Date])
var _date = SELECTEDVALUE('Table'[Date])
return
IF(
_selecteddate = _date,
1,0
)
Then you need to put them to the corresponding visual level filter and use date column from 'Calendar table as a slicer to filter the result.
'Visual control 1':
Visual control 2:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @kitti
If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.
Best Regards
Allan
Hi, @kitti
Based on your description, I created data to reproduce your scenario.
Table:
Calendar(a calculated table):
Calendar = CALENDARAUTO()
You may create two measures as below. 'Visual control 1' is to display the data for the last 2 weeks of the selected date. 'Visual control 2' is to show the data on the selected date.
Visual control 1 =
var _selectedate = SELECTEDVALUE('Calendar'[Date])
var _date = SELECTEDVALUE('Table'[Date])
var _datediff = DATEDIFF(_date,_selectedate,DAY)
return
IF(
_datediff<=14&&_datediff>=0,
1,0
)
Visual control 2 =
var _selecteddate = SELECTEDVALUE('Calendar'[Date])
var _date = SELECTEDVALUE('Table'[Date])
return
IF(
_selecteddate = _date,
1,0
)
Then you need to put them to the corresponding visual level filter and use date column from 'Calendar table as a slicer to filter the result.
'Visual control 1':
Visual control 2:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you select a date from the slicer, by default visuals will filter based on that particular date.
But you can change the filter context using ALL(), ALLEXCEPT(),KEEPFILTERS(), REMOVEFILTERS() etc.
You have to define your measures using the above function. Try to understand its functionality, I hope you can implement your requirement.
reference
https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/
https://www.sqlbi.com/articles/using-keepfilters-in-dax/
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂