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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
varshajain
Microsoft Employee
Microsoft 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.

varshajain
Microsoft Employee
Microsoft Employee

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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