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
WilliamAzevedo
Helper III
Helper III

Highlight or filter rows based on hour values

Hi!

 

I have a table that stores data about car, drivers, dates, hours and locations/itineraries. The system that manages that data emits reports based on date, which gives me hundreds of lines per date and I would like to have it resumed in two periods of the day:

  • First info of the day and last info of the morning and
  • First info of the afternoon and last info of the day.

About that: it is expected that the driver stops at 12:00 and restart at 13:30 (give or take 15 minutes) but, much more than I would like, they don't follow that directive. So, in addition to the idea of last of the mornin and first of the afternoon, i would like to set a timespan of, let's say, 50 minutes between these two moments. Examples:

 

What I have:

MotoristaDataInícioFimPlacaLocalização
Driver04/04/202410:1610:42PlateLocation
Driver04/04/202410:1610:42PlateLocation
Driver04/04/202410:1610:42PlateLocation
Driver04/04/202411:4912:17PlateLocation
Driver04/04/202411:4912:17PlateLocation
Driver04/04/202414:0414:06PlateLocation
Driver04/04/202414:0814:32PlateLocation
Driver04/04/202414:0814:32PlateLocation
Driver04/04/202414:3314:34PlateLocation
Driver04/04/202414:3314:34PlateLocation
Driver04/04/202414:3515:18PlateLocation
Driver04/04/202414:3515:18PlateLocation
Driver04/04/202415:4416:05PlateLocation
Driver04/04/202415:4416:05PlateLocation
Driver04/04/202416:0716:51PlateLocation
Driver04/04/202416:0716:51PlateLocation
Driver04/04/202416:5517:24PlateLocation
Driver04/04/202416:5517:24PlateLocation
Driver04/04/202416:5517:24PlateLocation

 

What I would like:

MotoristaDataInícioFimPlacaLocalização
Driver04/04/202410:1610:42PlateLocation
Driver04/04/202410:1610:42PlateLocation
Driver04/04/202410:1610:42PlateLocation
Driver04/04/202411:4912:17PlateLocation
Driver04/04/202411:4912:17PlateLocation
Driver04/04/202414:0414:06PlateLocation
Driver04/04/202414:0814:32PlateLocation
Driver04/04/202414:0814:32PlateLocation
Driver04/04/202414:3314:34PlateLocation
Driver04/04/202414:3314:34PlateLocation
Driver04/04/202414:3515:18PlateLocation
Driver04/04/202414:3515:18PlateLocation
Driver04/04/202415:4416:05PlateLocation
Driver04/04/202415:4416:05PlateLocation
Driver04/04/202416:0716:51PlateLocation
Driver04/04/202416:0716:51PlateLocation
Driver04/04/202416:5517:24PlateLocation
Driver04/04/202416:5517:24PlateLocation
Driver04/04/202416:5517:24PlateLocation

 

Or:

MotoristaDataInícioFimPlacaLocalização
Driver04/04/202410:1610:42PlateLocation
Driver04/04/202411:4912:17PlateLocation
Driver04/04/202414:0414:06PlateLocation
Driver04/04/202416:5517:24PlateLocation

 

Thank you in advance for any help!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @WilliamAzevedo ,

Based on my testing, please try the following methods:

1.Create the simple table.

2.Open the Power Query editor, select Inicio column and choose Remove duplicates.

vjiewumsft_0-1715915417805.png

3.Close and Apply. Create the new column to filter the Time.

vjiewumsft_1-1715915433474.png

4.Create the new measure to highlight the rows.

Highlight morning = 
var hour_ = SELECTEDVALUE('Table'[Início])
var min_hour_morning = CALCULATE(MIN('Table'[Início]), ALLSELECTED('Table'),'Table'[Mor after] = "Morning")
var max_hour_morning = CALCULATE(MAX('Table'[Início]),ALLSELECTED('Table'), 'Table'[Mor after] = "Morning")

var min_hour = CALCULATE(MIN('Table'[Início]),ALLSELECTED('Table'), 'Table'[Mor after] = "Afternoon")
var max_hour = CALCULATE(MAX('Table'[Início]),ALLSELECTED('Table'), 'Table'[Mor after] = "Afternoon")
RETURN
IF(min_hour_morning = hour_, "red",
    IF(max_hour_morning = hour_, "red",
        IF(min_hour = hour_, "red",
            IF(max_hour = hour_, "red"
            )
        )
    )
)

 

 

5.Select the Hour column and choose conditional formatting.

vjiewumsft_3-1715915450045.png

6.Select the Field value and choose Highlight morning measure.

 

vjiewumsft_4-1715915483097.png

7.The result is shown below.

vjiewumsft_5-1715915491637.png

Best Regards,

Wisdom Wu

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

4 REPLIES 4
WilliamAzevedo
Helper III
Helper III

Since we're here: if my table has multiple dates, is it possible to apply this on each date?

Anonymous
Not applicable

Hi @WilliamAzevedo ,

Based on my testing, please try the following methods:

1.Create the simple table.

2.Open the Power Query editor, select Inicio column and choose Remove duplicates.

vjiewumsft_0-1715915417805.png

3.Close and Apply. Create the new column to filter the Time.

vjiewumsft_1-1715915433474.png

4.Create the new measure to highlight the rows.

Highlight morning = 
var hour_ = SELECTEDVALUE('Table'[Início])
var min_hour_morning = CALCULATE(MIN('Table'[Início]), ALLSELECTED('Table'),'Table'[Mor after] = "Morning")
var max_hour_morning = CALCULATE(MAX('Table'[Início]),ALLSELECTED('Table'), 'Table'[Mor after] = "Morning")

var min_hour = CALCULATE(MIN('Table'[Início]),ALLSELECTED('Table'), 'Table'[Mor after] = "Afternoon")
var max_hour = CALCULATE(MAX('Table'[Início]),ALLSELECTED('Table'), 'Table'[Mor after] = "Afternoon")
RETURN
IF(min_hour_morning = hour_, "red",
    IF(max_hour_morning = hour_, "red",
        IF(min_hour = hour_, "red",
            IF(max_hour = hour_, "red"
            )
        )
    )
)

 

 

5.Select the Hour column and choose conditional formatting.

vjiewumsft_3-1715915450045.png

6.Select the Field value and choose Highlight morning measure.

 

vjiewumsft_4-1715915483097.png

7.The result is shown below.

vjiewumsft_5-1715915491637.png

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It worked greatly! Thank you very much!

WilliamAzevedo
Helper III
Helper III

I thought of part of the solution: using Power Query, I created a column merging "Data", "Placa", "Início" and "Fim"; then i removed the duplicates and the table has got around 90% smaller.

Now I need to find how to remove the rows between start and end of the morning and start and end of the afternoon, or highlight them!

Any help is appreciated and thank you!

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