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
Anonymous
Not applicable

Dynamic yesterday until specific time and today date

Hi all

I need a measure to show dynamic yesterday and today date.

 

The logic is show yesterday's date until today 3:00 PM (Australian time) and after this time show today's date.

 

Then I will use this in a measure to sum up sales and a text to show in the dashboard which day is showing up.

 

Any ideas if that is possible?

 

Cheers,

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

Hi, @Anonymous 

 

According to your description, I think you can easily create a calculated column to show the results.

Like this:

Column =
VAR a =
    HOUR ( 'Table'[Column1] )
RETURN
    IF (
        a <= 15,
        DATE ( YEAR ( 'Table'[Column1] ), MONTH ( 'Table'[Column1] ), DAY ( 'Table'[Column1] ) ) - 1,
        DATE ( YEAR ( 'Table'[Column1] ), MONTH ( 'Table'[Column1] ), DAY ( 'Table'[Column1] ) )
    )

v-janeyg-msft_1-1620294181505.png

 

v-janeyg-msft_0-1620294028330.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

4 REPLIES 4
v-janeyg-msft
Community Support
Community Support

Hi, @Anonymous 

 

According to your description, I think you can easily create a calculated column to show the results.

Like this:

Column =
VAR a =
    HOUR ( 'Table'[Column1] )
RETURN
    IF (
        a <= 15,
        DATE ( YEAR ( 'Table'[Column1] ), MONTH ( 'Table'[Column1] ), DAY ( 'Table'[Column1] ) ) - 1,
        DATE ( YEAR ( 'Table'[Column1] ), MONTH ( 'Table'[Column1] ), DAY ( 'Table'[Column1] ) )
    )

v-janeyg-msft_1-1620294181505.png

 

v-janeyg-msft_0-1620294028330.png

If it doesn’t solve your problem, please feel free to ask me.

 

Best Regards

Janey Guo

 

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

AllisonKennedy
Super User
Super User

@Anonymous  Do you have a dimdate table? I would add a current date offset to this table- that will enable you to filter for today, yesterday, two days ago, etc.

 

In your Fact/Transaction table you can use Power Query to add a new column that converts the datetime into Date only based on the time of day. This will likely require a few calculated columns and conditional statements, or manual M code. Let us know if you have ability to use calc columns in Power Query and we can provide more specific formulas for that if needed. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

Hi @AllisonKennedy

 

Yes I have a DIM date and I also have access to the power query

@Anonymous  that's great- has adding a column to date table and creating the relationship helped solve your problem? If not, please advise what step you're up to, where you need help and what's going wrong if anything.


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.