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
GustavoKamchen
Frequent Visitor

Filter Max hour by Date

Hello everybody.

 

I want to filter the table below to show me the column "Production" for the maximum hour of every day. How can I do this?

 

DateHourProduction
01/01/202205:00:0010
01/01/202206:00:0020
01/01/202207:00:0030
01/01/202208:00:0040
01/01/202209:00:0050
01/01/202210:00:0060
01/01/202211:00:0070
01/01/202212:00:0080
01/01/202213:00:0090
01/01/202214:00:00100
01/01/202215:00:00110
01/01/202216:00:00120
01/01/202217:00:00130
01/01/202218:00:00140
01/01/202219:00:00150
01/01/202220:00:00160
01/01/202221:00:00170
01/01/202222:00:00180
01/01/202223:00:00190
02/01/202205:02:039
02/01/202206:01:5918
02/01/202207:01:5527
02/01/202208:01:5136
02/01/202209:01:4745
02/01/202210:01:4354
02/01/202211:01:3963
02/01/202212:01:3572
02/01/202213:01:3181
02/01/202214:01:2790
02/01/202215:01:2399
02/01/202216:01:19108
02/01/202217:01:15117
02/01/202218:01:11126
02/01/202219:01:07135
02/01/202220:01:03144
02/01/202221:00:59153
02/01/202222:00:55162
1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @GustavoKamchen,

You can create a calculated column with the following formula to use the current date to find 'hour', then use the above 'hour' and current date to get the corresponding Production values.

formula =
VAR _maxhour =
    CALCULATE (
        MAX ( Table[Hour] ),
        FILTER ( Table, [Date] = EARLIER ( Table[Date] ) )
    )
RETURN
    CALCULATE (
        MAX ( Table[Production] ),
        FILTER ( Table, [Date] = EARLIER ( Table[Date] ) && [Hour] = _maxhour )
    )

EARLIER, EARLIEST – DAX Guide - SQLBI

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
PVO3
Impactful Individual
Impactful Individual

If you would like to create a table:

Table =
SUMMARIZE(
    Data,
    Data[Date],
    "Hour",
    MAX(Data[Hour]),
    "Production",
    CALCULATE(MIN(Data[Production]), SELECTEDVALUE(Data[Date])=Data[Date], MAX(Data[Hour]) = Data[Hour])
)

 

Result:

PVO3_0-1666334040311.png

You might want to format or change the hour column according to your needs.

 

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-shex-msft
Community Support
Community Support

HI @GustavoKamchen,

You can create a calculated column with the following formula to use the current date to find 'hour', then use the above 'hour' and current date to get the corresponding Production values.

formula =
VAR _maxhour =
    CALCULATE (
        MAX ( Table[Hour] ),
        FILTER ( Table, [Date] = EARLIER ( Table[Date] ) )
    )
RETURN
    CALCULATE (
        MAX ( Table[Production] ),
        FILTER ( Table, [Date] = EARLIER ( Table[Date] ) && [Hour] = _maxhour )
    )

EARLIER, EARLIEST – DAX Guide - SQLBI

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

How can I calculate average of daily production?

Hello,

 

I wrote there my question. https://community.powerbi.com/t5/Desktop/Show-only-data-from-the-latest-date/m-p/2852862/highlight/t...

 

So i saw yor codes and i have tried but nothing happened. There was no error. 

 

Can you help me?

 

note: I don't want to see earlier dates, i need last date and hour line.

 

Thak you 

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.