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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
JD0963
Helper I
Helper I

Flag to show data from 4PM yesterday to 4PM today?


Hi. hopefully someone can help with this. I have an SSAS cube in which I want to add a calculated column which I will use to filter data in Power BI.

 

The field I am working with is called "date created" (datetime data type)

I basically want a flag that I can use to only show data from 4PM onwards - for example, if a user viewed the report at 8am today, it would show them data from 4PM yesterday up until 8am today. If the user viewed it at 5:30pm today it would show data from 4PM today up until 5:30pm today - does that make sense? It would be as if 4pm was the start of a new day.

 

Thank you for any help. I appreciate it.

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @JD0963,

 

First, please generate the datetime range so that we can filter displayed data.

 

Please refer to these measures:

Now = NOW()
Start time = TODAY()+TIME(16,0,0)
Min time = IF([Now]>[Start time],[Start time],TODAY()-1+TIME(16,0,0))
Max Time = [Now]

Then, you can use measures [Min time] and [Max Time] to filter report data, similar to:

view data =
CALCULATE (
    SUM ( 'Table 2'[Sales] ),
    FILTER (
        'Table 2',
        'Table 2'[date created] >= [Min time]
            && 'Table 2'[date created] <= [Max Time]
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

1 REPLY 1
v-yulgu-msft
Employee
Employee

Hi @JD0963,

 

First, please generate the datetime range so that we can filter displayed data.

 

Please refer to these measures:

Now = NOW()
Start time = TODAY()+TIME(16,0,0)
Min time = IF([Now]>[Start time],[Start time],TODAY()-1+TIME(16,0,0))
Max Time = [Now]

Then, you can use measures [Min time] and [Max Time] to filter report data, similar to:

view data =
CALCULATE (
    SUM ( 'Table 2'[Sales] ),
    FILTER (
        'Table 2',
        'Table 2'[date created] >= [Min time]
            && 'Table 2'[date created] <= [Max Time]
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.