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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
deb_power123
Helper V
Helper V

How to exclude rows selecting date slicer max and min date ranges

Hi All,

 

As per the below scenario,I need to exclude all the rows in the table Sales with columns Client,sales,salesdate and region which fall outside the selected maximum and minimum date range of the date slider.

Could anyone please suggest a DAX , I will share my DAX query which is not working.I tried to search official guides in PowerBI for selectedValues() to handle this date filter condition but nothing seems to be working.

 

I created a Calendar table with distinct values of the dates as present in the Sales Dates column of the Sales table. There is no relationship between these two tables.

 

I used the below DAX measures to handle the filtering criteria for excluding the rows:-

Below measures are meant to find maximum and minimum dates in the selection slider

MaxDate=MAX(DateDimention[Dates])

MinDate=MIN(DateDimention[Dates])

Below  ExcludedMeasure is meant to set 1 flag to the values other than  selected values which are selected for both min and max dates. I dragged and dropped it in the visual filter of my table Sales and set it to dont show.But it seems to be not working.

Please suggest how can I fix it.

ExcludeMeasure = IF (SELECTEDVALUE(Calendar,Calendar[MinDate],0,1),

                              IF (SELECTEDVALUE(Calendar,Calendar[MaxDate],0,1)

 

 

My Present Visualization and indepedent Calendar table to be used in the filter slider:-

12.JPG

13.JPG

 

Input data source [Excel]

 

ClientSalesSalesDatesRegion
A10001.1.2000USA
A1001.2.2000USA
A2004.3.2000USA
B1104.3.2000Europe
B10005.4.2000Europe
B2006.8.2001Europe
C11007.9.2001Asia
C20008.12.2001Asia
D1001.2.2002Australia
D13006.3.2002Australia
E1007.5.2002Africa

 

Expected Results :

 

If I select Minium slider date as 01.04.2001 and maximum slider date as 1.09.2001 in my[Dates] filter visualization, then it should return the below results after exluding '5.4.2001' and '6.8.2001':-

 

ClientSalesSalesDatesRegion
A10001.1.2000USA
A1001.2.2000USA
A2004.3.2000USA
B1104.3.2000Europe
C11007.9.2001Asia
C20008.12.2001Asia
D1001.2.2002Australia
D13006.3.2002Australia
E1007.5.2002Africa

 

Kind regards

Sameer

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

Hi, @deb_power123 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.(All dates are in 'mm/dd/yyyy' format)

Table:

a1.png

 

DateDimention(a calculated table):

DateDimention = CALENDARAUTO()

 

There is no relationship between two tables. You may create a measure as below.

Visual Control = 
IF(
    SELECTEDVALUE('Table'[SalesDates])<MIN(DateDimention[Date])||
    SELECTEDVALUE('Table'[SalesDates])>MAX(DateDimention[Date]),
    1,0
)

 

Finally you need to put the measure in the visual level filter and use 'Date' column from 'DateDimention' table to filter the result.

a2.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

4 REPLIES 4
v-alq-msft
Community Support
Community Support

Hi, @deb_power123 

 

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.(All dates are in 'mm/dd/yyyy' format)

Table:

a1.png

 

DateDimention(a calculated table):

DateDimention = CALENDARAUTO()

 

There is no relationship between two tables. You may create a measure as below.

Visual Control = 
IF(
    SELECTEDVALUE('Table'[SalesDates])<MIN(DateDimention[Date])||
    SELECTEDVALUE('Table'[SalesDates])>MAX(DateDimention[Date]),
    1,0
)

 

Finally you need to put the measure in the visual level filter and use 'Date' column from 'DateDimention' table to filter the result.

a2.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.

Payeras_BI
Super User
Super User

Hi @deb_power123 ,

Please use the comma "," instead of  semicolon ";" as separator.

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Payeras_BI
Super User
Super User

Hi @deb_power123 ,
I believe you can get what you want like this:

Payeras_BI_0-1613728670664.png

Payeras_BI_2-1613729074767.png

 

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

Hi ,

Thankyou for the response.I tried  but i am getting the below error message while trying to create the measure.

 

Could you please share the .pbix file or let me know where i am making mistake?error.JPG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors