Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kitti
Helper III
Helper III

different types of multiple visuals filtering with a date segmentation

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

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @kitti 

Based on your description, I created data to reproduce your scenario.

Table:

b1.png

 

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':

b2.png

 

Visual control 2:

b3.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-alq-msft
Community Support
Community Support

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

v-alq-msft
Community Support
Community Support

Hi, @kitti 

Based on your description, I created data to reproduce your scenario.

Table:

b1.png

 

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':

b2.png

 

Visual control 2:

b3.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

nandukrishnavs
Super User
Super User

@kitti 

 

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/

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept...


Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂


Regards,
Nandu Krishna

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.