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
saipawar
Helper IV
Helper IV

Dynamic text field based on current date

Hi, 

 

I want to display "currently you are in <Phase 1>, 22 days to go for the event"

- Currently means today's date

- <Phase 1> will be picked from a lookup up below

- countdown wrt to Phase 3 date

PhaseDate 
Phase 1Monday, June 12,2023 
Phase 2Tuesday, August 1,2023 
Phase 3Tuesday, October 17, 2023

 

1 ACCEPTED SOLUTION
v-huijiey-msft
Community Support
Community Support

Hi @saipawar ,

 

Thanks for the reply from @PhilipTreacy , like he said, I do not quite understand your needs, I can only do what I can to help you.

 

Based on the table you provided, I am not sure why today is part of phase 1 and why it is 22 days.

 

My understanding is this:

 

First determine the phase you currently belong to based on today is date, then calculate the number of days between today and Phase 3.

 

If today is date is earlier than Phase 1 then it belongs to Phase 1, if today is date is earlier than Phase 2 then it belongs to Phase 2, if today is date is earlier than Phase 3 then it belongs to Phase 3.

 

I modified the example data as follows:

Phase

Date

Phase 1

6/12/2024

Phase 2

8/1/2024

Phase 3

10/17/2024

 

First, create a measure to calculate the phase to which the current date belongs:

 

Current Phase =
VAR TodayDate =
    TODAY ()
RETURN
    IF (
        TodayDate
            < CALCULATE (
                MAX ( 'Phases'[Date] ),
                FILTER ( 'Phases', 'Phases'[Phase] = "Phase 1" )
            ),
        "Phase 1",
        IF (
            TodayDate
                < CALCULATE (
                    MAX ( 'Phases'[Date] ),
                    FILTER ( 'Phases', 'Phases'[Phase] = "Phase 2" )
                ),
            "Phase 2",
            "Phase 3"
        )
    )

 

 

Next, calculate the date interval between today and the Phase 3 date:

 

Countdown to Phase 3 =
VAR Phase3Date =
    CALCULATE (
        MAX ( 'Phases'[Date] ),
        FILTER ( 'Phases', 'Phases'[Phase] = "Phase 3" )
    )
RETURN
    DATEDIFF ( TODAY (), Phase3Date, DAY )

 

 

Then, apply dynamic text formatting, which will change dynamically based on today is date:

 

Dynamic Text =
"Currently, you are in " & [Current Phase] & ", "
    & ABS ( [Countdown to Phase 3] ) & " days to go for the event."

 

 

Finally, the Dynamic Text is dragged to the card visual object for display, and the page visualization looks like the following:

vhuijieymsft_0-1714373040333.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

2 REPLIES 2
v-huijiey-msft
Community Support
Community Support

Hi @saipawar ,

 

Thanks for the reply from @PhilipTreacy , like he said, I do not quite understand your needs, I can only do what I can to help you.

 

Based on the table you provided, I am not sure why today is part of phase 1 and why it is 22 days.

 

My understanding is this:

 

First determine the phase you currently belong to based on today is date, then calculate the number of days between today and Phase 3.

 

If today is date is earlier than Phase 1 then it belongs to Phase 1, if today is date is earlier than Phase 2 then it belongs to Phase 2, if today is date is earlier than Phase 3 then it belongs to Phase 3.

 

I modified the example data as follows:

Phase

Date

Phase 1

6/12/2024

Phase 2

8/1/2024

Phase 3

10/17/2024

 

First, create a measure to calculate the phase to which the current date belongs:

 

Current Phase =
VAR TodayDate =
    TODAY ()
RETURN
    IF (
        TodayDate
            < CALCULATE (
                MAX ( 'Phases'[Date] ),
                FILTER ( 'Phases', 'Phases'[Phase] = "Phase 1" )
            ),
        "Phase 1",
        IF (
            TodayDate
                < CALCULATE (
                    MAX ( 'Phases'[Date] ),
                    FILTER ( 'Phases', 'Phases'[Phase] = "Phase 2" )
                ),
            "Phase 2",
            "Phase 3"
        )
    )

 

 

Next, calculate the date interval between today and the Phase 3 date:

 

Countdown to Phase 3 =
VAR Phase3Date =
    CALCULATE (
        MAX ( 'Phases'[Date] ),
        FILTER ( 'Phases', 'Phases'[Phase] = "Phase 3" )
    )
RETURN
    DATEDIFF ( TODAY (), Phase3Date, DAY )

 

 

Then, apply dynamic text formatting, which will change dynamically based on today is date:

 

Dynamic Text =
"Currently, you are in " & [Current Phase] & ", "
    & ABS ( [Countdown to Phase 3] ) & " days to go for the event."

 

 

Finally, the Dynamic Text is dragged to the card visual object for display, and the page visualization looks like the following:

vhuijieymsft_0-1714373040333.png

 

The pbix file is attached.

 

If you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

PhilipTreacy
Super User
Super User

Hi @saipawar 

 

Your request is too vague.

 

How do we know what phase has been seelcted?

 

Where do you want this information displayed?  In a card visual?

 

If the countodwn is wrt to the Phase3 date, and you are in Phase 1, based on your table, there would be more than 22 days to go.

 

Please provide more information and answers to the above.

 

Regards

 

Phil

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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.