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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.