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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
alfertab
Helper I
Helper I

Show the last date in a graphic but with the possibility of using data segmentation to see historics

Hi everyone, 

 

I'm having some troubles with Power BI Desktop and I was wondering if someone could help me. Basically what I'm trying to do is to filter the X axis on a line chart and showing only the values for the last day (each day have data for their respective 24 hours and I need to show the data of each hour). The problem that I'm having right now is that I also need to add a data segmentation in case anyone need to watch the historical data. Does anyone knows if that's possible and how?

2 REPLIES 2
v-qiaqi-msftv
Community Support
Community Support

Hi @alfertab,

Thanks for the reply from AnushaSri.

 

I have another way to achieve  your need, you could add a dateonly slicer since you want to add a data segmentation in case anyone need to watch the historical data.

 

Here are the detailed steps:

1). Add two columns separately for hour only and date only:

HourOnly = FORMAT('Table'[DateTime], "HH:00")

DateOnly = DATE(YEAR('Table'[DateTime]), MONTH('Table'[DateTime]), DAY('Table'[DateTime]))

 

2). Create a measure named LastAvailableDate to retrieves the maximum available date:

LastAvailableDate = MAX('Table'[DateTime])

 

3). Create a measure named SelectedOrLastDate to filter Data Based on Selection or Last Date:

SelectedOrLastDate =
VAR SelectedDate = MAX('Table'[DateOnly]) -- Ensure it picks only the date
VAR LastAvailableDate = CALCULATE(MAX('Table'[DateOnly]), ALL('Table'))
RETURN
IF(ISFILTERED('Table'[DateOnly]), SelectedDate, LastAvailableDate)

 

4). Create a measure named DataForLastOrSelectedDate to display last date if tehre is no selected date:

DataForLastOrSelectedDate =
VAR SelectedDate = [SelectedOrLastDate]
RETURN
CALCULATE(
SUM('Table'[Value]), -- Replace with your actual measure
'Table'[DateTime] >= SelectedDate && 'Table'[DateTime] < SelectedDate + 1
)

5). Configrue the visual as below:

vqiaqimsftv_1-1739246069317.png
Also, remember to edit interaction as below, which will allows the slicer filters the line chart:
vqiaqimsftv_2-1739246100968.png

 

Best Regards,
Qi
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

AnushaSri
Resolver II
Resolver II

Add a drill down to your chart, so that selecting a day data point would drill down to show you 24 hours data of that selected day data point.

 

Please mark this as solution accepted, if my answer help you resolve your issue.

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.