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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Jason2500
Helper I
Helper I

How to use IF condition for the slicers?

Hi

 

I have two tables, one is the date

 

Jason2500_0-1617570542271.png

I have created this date column using calendar auto function

 

Another table called user 

 

Jason2500_1-1617570760770.png

There is no a relationship between these two tables. 

I have created a slicer using my date column

 

Jason2500_2-1617570793616.png

 

I want to check whether the user table date available in the selected slicer date using the If condition. For example, in the User table Player A has a date of January 1 2021. I want to check whether Jan 1 2021 lies between the selected slicer date. If it is available I need to print 1 else 0. 

 

I want to create a DAX measure to check this condition. Not sure how to do this. Tried other posts but no success. Please advise. 

 

 

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi, @Jason2500 

Please try to write the below measure.

The link to the sample pbix file is down below.

 

Picture4.png

 

Check measure =
IF (
SELECTEDVALUE ( Users[Date] ) >= MIN ( Dates[Date] )
&& SELECTEDVALUE ( Users[Date] ) <= MAX ( Dates[Date] ),
1,
0
)

 

https://www.dropbox.com/s/2vc7txlkggjn22q/jason2500.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi, @Jason2500 

Please try to write the below measure.

The link to the sample pbix file is down below.

 

Picture4.png

 

Check measure =
IF (
SELECTEDVALUE ( Users[Date] ) >= MIN ( Dates[Date] )
&& SELECTEDVALUE ( Users[Date] ) <= MAX ( Dates[Date] ),
1,
0
)

 

https://www.dropbox.com/s/2vc7txlkggjn22q/jason2500.pbix?dl=0 

 

Hi, My name is Jihwan Kim.

If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

selimovd
Super User
Super User

Hey @Jason2500 ,

 

you can tell Power BI to treat the date column from the date table as the date column from the user table.

Try the following measure and add it in the visualization to a table with the Player column from the user table:

 

Amount Rows =
CALCULATE(
    COUNTROWS( user ),
    TREATAS(
        VALUES( 'date'[Date] ),
        user[Date]
    )
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

@selimovd  Thanks for your help.  I tried the above measures, but it is not checking the condition. I need to see whether the user date is available between the slicer and show 1 else 0? Can you please advise?

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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