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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Sajids39
Frequent Visitor

IF statement with date column as a measure

Hi,

 

I am new to this community and looking for a help with a measure (dax) having if statement on date column.

 

I have one date slicer where the date is coming from a "Date" table. I have another table called "Online/Offline" where I have made a relationship as below.

Community-1.PNG

 

Now, I wanted to insert one measure with the below logic.

IF the date selected is less than equal to (<=) "7/31/2022" then return 480, if the date selected is >= "8/1/2022" and ResearcherName (which is a text column in "Online/Offline" table) = "Sajid (it could be any other researcher name)" then return 440 or else 385.

 

I have applied one dax as below, but it is not giving me the desired result.

Community-2.PNG

 

Result that I am getting is,

 

Community-3.PNG

As you can see above in highlighted, The date selected is 8/1/2022 till 8/4/2022 but the value that I am getting is 480 for all the researchers.

 

The expected result for the date selected >= 8/1/2022

Community- 4.PNG

 

The expected result for the date selected <= 7/31/2022

community-5.PNG

 

It would be a great help if somebody can help me in this.

 

Many thanks in advance.

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Because your date slicer is a range SELECTEDVALUE('Date'[Date]) won't work - there is not a single value. You would need to either change the slicer to a list or dropdown, forcing the user to select a single date, or else change the SELECTEDVALUE('Date'[Date]) to MIN('Date'[Date]) or MAX('Date'[Date]), depending on which is more appropriate for your use case.

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Because your date slicer is a range SELECTEDVALUE('Date'[Date]) won't work - there is not a single value. You would need to either change the slicer to a list or dropdown, forcing the user to select a single date, or else change the SELECTEDVALUE('Date'[Date]) to MIN('Date'[Date]) or MAX('Date'[Date]), depending on which is more appropriate for your use case.

Hi @johnt75 

 

This is working now. Thanks a ton 🙂

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.