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
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
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.