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
mayankgupta3090
Regular Visitor

How to get the data of 24 hr from the current time but of user selected date

I have the data in my table for every 15 minutes.  Now user wnat to see the data for previous 24 hr from current time but of the selected. Suppose today is 05-May-2019 and user open the report today at 10:30 AM and selected the date of 27-April-2019 then report should contain the data from 26-Apr-2019 10:30AM to 27-APR-2019 10:30 AM. That means user want to see the data of last 24 hr of current time but of his selected date. I tried multiple solutions but nothing worked. Its urgent, earlies help is very much appreciable. I have multiple measures so I can't create individual calculation for each measure therefore I want something that can be applied as report level filter.

 

Thanks in advance!!!

1 ACCEPTED SOLUTION

I found the solution by following approach

1. Created the Calendar Table having Date,month,year column 

2. Lets call my data table as TblData and made no relation with Calendar Table

3. Use slicer to filter one month name of Calendar Table (drop Down)

4. Use another slicer to filter on Date field of Calendar Table (Drop Down)

5. Created Measure, Number of Records=1

6. Created another Measure, Isin4Hour =

Calculate (Max([Number of Records]),

                Filter('TblData', (('TblData'[DateTime].Date=(selectedValue('Calendar'[Date])-1) && TimeValue(TblData'[DateTime])>=TimeValue(Now()))

               || ('TblData'[DateTime].Date=(selectedValue('Calendar'[Date])) && TimeValue(TblData'[DateTime])<=TimeValue(Now()))

7. Put this measure on Visual Filter ans selce filter condition 'is=1'.

 

Now you will have the data of previous 24 hr of selected date from current time.


Thanks, Please do comment you scenario in which this approach is useful so that I can learn.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

can you post some sample data of your tables?

Due to privacy, I am sharing sample dummy data. Now suppose User open the report  today @ 8:30 and  selected 02-03-2019, then report should contain only data from 01-03-20 8:30 to 02-03-2019 8:30. I have 50+ measures in my real dataset. Please help @Anonymous 

S.NoEntityDateTimeMeasure1
1A01-03-2019 08:002
2A01-03-2019 08:304
3A01-03-2019 18:0020
4A02-03-2019 01:3022
5A02-03-2019 02:0024

Request you to please help.

I found the solution by following approach

1. Created the Calendar Table having Date,month,year column 

2. Lets call my data table as TblData and made no relation with Calendar Table

3. Use slicer to filter one month name of Calendar Table (drop Down)

4. Use another slicer to filter on Date field of Calendar Table (Drop Down)

5. Created Measure, Number of Records=1

6. Created another Measure, Isin4Hour =

Calculate (Max([Number of Records]),

                Filter('TblData', (('TblData'[DateTime].Date=(selectedValue('Calendar'[Date])-1) && TimeValue(TblData'[DateTime])>=TimeValue(Now()))

               || ('TblData'[DateTime].Date=(selectedValue('Calendar'[Date])) && TimeValue(TblData'[DateTime])<=TimeValue(Now()))

7. Put this measure on Visual Filter ans selce filter condition 'is=1'.

 

Now you will have the data of previous 24 hr of selected date from current time.


Thanks, Please do comment you scenario in which this approach is useful so that I can learn.

 

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.