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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
EFI
Helper I
Helper I

Slicer with days AND hours ?

Hello there,

 

I start creating a dashboard to monitor the energy comsumption in some of our plants and I encounter some issue with the timestemp / slicer, I try some workaround but couldn't find something working properly.

 

Is there a way to create an hour slicer ? (slicer is not mandatory of course, but I would want be able to "play" with hours a way or another).

 

I try to put an exemple below of what we would want, I hope its clear enough.

 

Also the .pbix file : https://drive.google.com/file/d/11m5hYVyLFd5XEfb1A4L2pIjWxpfpkh_Y/view?usp=sharing

 

2024-10-23 15_23_06-DI_sample.png

 

Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @EFI ,

Regarding your question, 'Between' style slicers can only have values from small to large by default. How about creating two slicers?

I added a rectangle to cover the excess slicer section.

vzhouwenmsft_0-1730688770152.png

vzhouwenmsft_1-1730688829411.png

 

MEASURE = 
VAR _startHour =
    MIN ( 'BeginHour'[Hour] )
VAR _endHour =
    MAX ( 'EndHour'[Value] )
VAR _startDate =
    MIN ( 'Calendar'[Date] )
VAR _endDate =
    MAX ( 'Calendar'[Date] )
VAR _curren_x_axis_date_hour =
    SELECTEDVALUE ( ENERGY[timestamputc] )
VAR _curren_x_axis_date =
    SELECTEDVALUE ( ENERGY[timestamputc - Date] )
VAR _result =
    IF (
        _curren_x_axis_date = _startDate
            && HOUR ( _curren_x_axis_date_hour ) >= _startHour,
        SUM ( ENERGY[value] ),
        IF (
            _curren_x_axis_date = _endDate
                && HOUR ( _curren_x_axis_date_hour ) <= _endHour,
            SUM ( ENERGY[value] ),
            IF (
                _curren_x_axis_date <> _startDate
                    && _curren_x_axis_date <> _endDate,
                SUM ( ENERGY[value] )
            )
        )
    )
RETURN
    _result

 


Best Regards,
Wenbin Zhou

 

 

View solution in original post

15 REPLIES 15
Anonymous
Not applicable

Hi Thejeswar ,thanks for the quick reply, I'll add more.

Hi @EFI ,

For some reason I can't download the .pbix file you provided at the moment, but I think your timestamps should be about the same as the data I'm assuming.

vzhouwenmsft_0-1729834987400.png

Please follow these steps:

Create two columns, one for the date slicer and one for the hour slicer.

Time.Hour([DateTime]))

vzhouwenmsft_1-1729835116992.png

2.Creating a Date Dimension Table and an Hour Dimension Table

DateTable = CALENDAR(DATE(2024,1,1),DATE(2024,1,10))
HourTable = GENERATESERIES(0,24,1)

vzhouwenmsft_2-1729835453405.png

Final output

vzhouwenmsft_4-1729835730189.png

vzhouwenmsft_5-1729835788925.png

 

 


Best Regards,
Wenbin Zhou

Hi,

 

I will try to do a separate hour table and see how that work, thank you.

 

I try to re upload my .pbix from a non corporate goog drive account, can you try again and see if its work now ? : https://drive.google.com/file/d/1vbvg6udr8wUQbPG4BfDvG03MHUvQRNTo/view?usp=sharing

Anonymous
Not applicable

Hi @EFI ,

It should work fine.

vzhouwenmsft_0-1730100892221.png

vzhouwenmsft_1-1730100956272.png

 

Due to exceeding the file size limit for uploads, I will not upload it. The steps should not have any issues.


Best Regards,
Wenbin Zhou

Did you change any relation between the table from te original .pbix ?

 

I try it but keep getting blank on the graph.

 

Thank you for your support.

Anonymous
Not applicable

Hi @EFI ,

I created a relationship between the fact table and the hourly dimension table.Other unchanged

vzhouwenmsft_0-1730164259121.png

 

 

Best Regards,
Wenbin Zhou

@Anonymous Alright, its curious because its seems I do same thing as you but when I change the slicer, I get blank value every time.

 

PBIx : Solfcast/DI_sample

Anonymous
Not applicable

Hi @EFI ,

I found the cause of the problem.Column 'timestamputc' contains hour-minute part, which results in only “mm-dd-yyyyy 12:00:00AM” data being filtered.

vzhouwenmsft_0-1730254560547.png

 

Best Regards,
Wenbin Zhou

Oh right, didn't see I was still on the timestemp with the hour included.

 

Its great its moving forward thanks, but its more complex than that in fact :c

 

This is giving me the sum for every day between 10 and 12.

 

EFI_0-1730282469633.png

The goal was more to have a start hour and end hour and looking for all value between them.

EFI_1-1730282941076.png

 

I hope im clear enough with my paint skill 🙂

 

Anonymous
Not applicable

Hi @EFI ,

Correct me if I'm misunderstanding.

1.Delete the relationship between the hourly dimension table and the fact table

vzhouwenmsft_0-1730449015661.png

2.Use the following DAX expression to create a measure

MEASURE = 
VAR _startHour =
    MIN ( 'Hour'[Hour] )
VAR _endHour =
    MAX ( 'Hour'[Hour] )
VAR _startDate =
    MIN ( 'Calendar'[Date] )
VAR _endDate =
    MAX ( 'Calendar'[Date] )
VAR _curren_x_axis_date_hour =
    SELECTEDVALUE ( ENERGY[timestamputc] )
VAR _curren_x_axis_date =
    SELECTEDVALUE ( ENERGY[timestamputc - Date] )
VAR _result =
    IF (
        _curren_x_axis_date = _startDate
            && HOUR ( _curren_x_axis_date_hour ) >= _startHour,
        SUM ( ENERGY[value] ),
        IF (
            _curren_x_axis_date = _endDate
                && HOUR ( _curren_x_axis_date_hour ) <= _endHour,
            SUM ( ENERGY[value] ),
            IF (
                _curren_x_axis_date <> _startDate
                    && _curren_x_axis_date <> _endDate,
                SUM ( ENERGY[value] )
            )
        )
    )
RETURN
    _result

3.Final output

vzhouwenmsft_1-1730449111046.png

vzhouwenmsft_2-1730449142072.png

 

Best Regards,
Wenbin Zhou

Hi, yes exacly, I was looking for something like this !

Can I ask you one more question, so its working perfect If I want to seach for exemple from 10 to 12, but could it work if I want to display from 23 to 09 ?

 

I think the slicer not letting me put superior value first.

EFI_0-1730558229498.png

 

Thank you very much for your support.

Anonymous
Not applicable

Hi @EFI ,

Regarding your question, 'Between' style slicers can only have values from small to large by default. How about creating two slicers?

I added a rectangle to cover the excess slicer section.

vzhouwenmsft_0-1730688770152.png

vzhouwenmsft_1-1730688829411.png

 

MEASURE = 
VAR _startHour =
    MIN ( 'BeginHour'[Hour] )
VAR _endHour =
    MAX ( 'EndHour'[Value] )
VAR _startDate =
    MIN ( 'Calendar'[Date] )
VAR _endDate =
    MAX ( 'Calendar'[Date] )
VAR _curren_x_axis_date_hour =
    SELECTEDVALUE ( ENERGY[timestamputc] )
VAR _curren_x_axis_date =
    SELECTEDVALUE ( ENERGY[timestamputc - Date] )
VAR _result =
    IF (
        _curren_x_axis_date = _startDate
            && HOUR ( _curren_x_axis_date_hour ) >= _startHour,
        SUM ( ENERGY[value] ),
        IF (
            _curren_x_axis_date = _endDate
                && HOUR ( _curren_x_axis_date_hour ) <= _endHour,
            SUM ( ENERGY[value] ),
            IF (
                _curren_x_axis_date <> _startDate
                    && _curren_x_axis_date <> _endDate,
                SUM ( ENERGY[value] )
            )
        )
    )
RETURN
    _result

 


Best Regards,
Wenbin Zhou

 

 

Great, I can workaround like this, thank you very much for your time and help on this topic @Anonymous 

Thejeswar
Super User
Super User

Hi @EFI ,

You can try using independent time tables for the hour slicer. with each table driving a slicer and these tables filtering the main table

 

Regards,

 

Hi,

 

You mean like a generic table with hour, like a calendar table ?

@EFI ,

Yes something like that. But this table should be connected to the main fact table. Try being a little innovative on where to have an active / inactive relatonship. 

 

Regards,

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors