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.
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:-
Input data source [Excel]
Client | Sales | SalesDates | Region |
A | 1000 | 1.1.2000 | USA |
A | 100 | 1.2.2000 | USA |
A | 200 | 4.3.2000 | USA |
B | 110 | 4.3.2000 | Europe |
B | 1000 | 5.4.2000 | Europe |
B | 200 | 6.8.2001 | Europe |
C | 1100 | 7.9.2001 | Asia |
C | 2000 | 8.12.2001 | Asia |
D | 100 | 1.2.2002 | Australia |
D | 1300 | 6.3.2002 | Australia |
E | 100 | 7.5.2002 | Africa |
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':-
Client | Sales | SalesDates | Region |
A | 1000 | 1.1.2000 | USA |
A | 100 | 1.2.2000 | USA |
A | 200 | 4.3.2000 | USA |
B | 110 | 4.3.2000 | Europe |
C | 1100 | 7.9.2001 | Asia |
C | 2000 | 8.12.2001 | Asia |
D | 100 | 1.2.2002 | Australia |
D | 1300 | 6.3.2002 | Australia |
E | 100 | 7.5.2002 | Africa |
Kind regards
Sameer
Solved! Go to Solution.
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:
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.
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, @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:
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.
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 @deb_power123 ,
Please use the comma "," instead of semicolon ";" as separator.
Hi @deb_power123 ,
I believe you can get what you want like this:
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?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
101 | |
52 | |
21 | |
12 | |
11 |