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
giovanni_figuei
Frequent Visitor

Show a Text based on a Date

Hi. I need to show a text based on a Date but i can't think of a way to do that.

Heres the situation: I have a ID code wich have a lifetime, based on this life time i want to display a text informing if the code is Valid or not based on this date. Everything that is before the date of today will be listed as INVALID and everything after wil be listed as VALID.
The Slicer wich im using.

giovanni_figuei_0-1642008380809.png

The dates im using. it says 

giovanni_figuei_1-1642008419580.png
I want to lose this Multi row card and show only if it is valid or invalid.

Thank you for your time.

 

 

1 ACCEPTED SOLUTION

Hi, @giovanni_figuei 

 

Please check the following methods.

Measure = 
VAR N1 =
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( 'Table'[Date] ) >= DATE ( 2020, 4, 15 )
            && SELECTEDVALUE ( 'Table'[Date] ) <= DATE ( 2022, 12, 31 ), "VALID",
        SELECTEDVALUE ( 'Table'[Date] ) < DATE ( 2020, 4, 15 ), "INVALID",
        SELECTEDVALUE ( 'Table'[Date] ) > DATE ( 2022, 12, 31 ), "INVALID"
    )
RETURN
    N1

vzhangti_0-1642386867024.pngvzhangti_1-1642386898754.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Charlotte Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@giovanni_figuei 

The information you have provided is not making the problem clear to me. Can you please explain with an example.

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
Appreciate your Kudos.

I was thinking something with this logic :
IF (date of today)>(end date)
then (display "INVALID")
IF (Date of today)<(end date)
then (display "Valid")

 

Hi, @giovanni_figuei 

 

Please check the following methods.

Measure = 
VAR N1 =
    SWITCH (
        TRUE (),
        SELECTEDVALUE ( 'Table'[Date] ) >= DATE ( 2020, 4, 15 )
            && SELECTEDVALUE ( 'Table'[Date] ) <= DATE ( 2022, 12, 31 ), "VALID",
        SELECTEDVALUE ( 'Table'[Date] ) < DATE ( 2020, 4, 15 ), "INVALID",
        SELECTEDVALUE ( 'Table'[Date] ) > DATE ( 2022, 12, 31 ), "INVALID"
    )
RETURN
    N1

vzhangti_0-1642386867024.pngvzhangti_1-1642386898754.png

If the method I provided above can't solve your problem, what's your expected result? Could you please provide more details for it?

 

Best Regards,

Charlotte Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

Thank you so much helped me a lot S2

Hi thanks for the reply. This dates wich this codes are usable are classified for the users it is just me that have access to, them said that, i only want to show if the code is valid in the date of today not show the dates themselves. Like this: if the end date is tomorrow for exemple the code will be valid but if it is yesterday it will be invalid.
I want this to happen but this "VALID" text be responsive in the conditions i mentioned above 

giovanni_figuei_0-1642073466246.png

 

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.