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
varshajain
Employee
Employee

Relative date slicer not working in DAX

I have a Date slicer which is powered by Candidates table. I have another filter Stage also powered by Candidates table. If I select any option in Environment filter, I wish to take all the records from Candidates table for the given date range selected irrespective of Environemnt filter  and then perform further filtration depending on the option I selected from the Environment slicer.

I have this DAX formula so far but it doesn't seem to work. 

 

Result=
IF(
    SELECTEDVALUE(Candidates[Environment])=="Prod","This works fine",  
    IF(
        SELECTEDVALUE(Candidates[Environment])=="Pilot",
         CALCULATE(SUM(Candidates[TP]),
                    FILTER(ALL(Candidates),  Candidates[CreateDate] >= MINX(ALLSELECTED(Candidates[CreateDate]), Candidates[CreateDate].[Date]) && Candidates[CreateDate] <= MAXX(ALLSELECTED(Candidates[CreateDate]), Candidates[CreateDate].[Date]) &&  Candidates[Environment]== "Prod"
)),"NA" ))
 
Could someone help me with this and let me know what is it that I am doing wrong?
1 ACCEPTED SOLUTION
hymie
New Member

FILTER(ALL(Candidates) means include the entire Candidate table. So the following MINX includes all rows too. You need to create two variables at the top of the expresion to capture the min and max ALLSELECTED values, then use those variables in the FILTER.

View solution in original post

2 REPLIES 2
hymie
New Member

FILTER(ALL(Candidates) means include the entire Candidate table. So the following MINX includes all rows too. You need to create two variables at the top of the expresion to capture the min and max ALLSELECTED values, then use those variables in the FILTER.

Thank You! I added this and it worked

var _max = maxx(allselected('Candidates'[CreateDate]),'Candidates'[CreateDate])
var _min = minx(allselected('Candidates'[CreateDate]),'Candidates'[CreateDate])

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