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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Kudoed Authors