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

Question about finding max value in dataset

Hi all,

i have a question about finding the max value.

 

My dataset looks like the following:

NameDateTimeFull HourUnique keyValue
Theo01-01-202000:0000:00Theo 01-01-2020 00:0015
Theo01-01-202000:1500:00Theo 01-01-2020 00:0030
Theo01-01-202000:3000:00Theo 01-01-2020 00:0025
Theo01-01-202000:4500:00Theo 01-01-2020 00:0040
Theo01-01-202001:0001:00Theo 01-01-2020 01:0015
Theo01-01-202001:1501:00Theo 01-01-2020 01:0020
Theo01-01-202001:3001:00Theo 01-01-2020 01:0035
Theo01-01-202001:4501:00Theo 01-01-2020 01:0030
Theo01-01-202002:0002:00Theo 01-01-2020 02:0025
Frank01-01-202000:0000:00Frank 01-01-2020 00:0010

 

I have made a new table in which i have grouped the column unique key in a way that each unique key is there only once. And now i want to add a column with the max value per hour per uniqe key. So the table will look as following:

Unique keyMaxValue
Theo 01-01-2020 00:0040
Theo 01-01-2020 01:0035
Theo 01-01-2020 02:0025
Frank 01-01-2020 00:0010

 

Can someone help me? cause i can't figure out the formula needed here.

The column Unique key contains text.

 

Thanks in advance!

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Rinto ;

Sorry, I may be a little poor in understanding. Please give me the original table and the output result, so that I can have a clearer understanding of your logic.


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, @v-yalanwu-msft 

 

It probibly is a bit confusing. Therefore i will make a better description of what i'am trying to do.

I have two sets of data:

- 1 set of data consists of about 200 meters with quarterly (electricity) or hourly data (gas) for a whole year

- 1 set of data consists of about 100 buildings with caracteristics of these building including the meters which are part of these buildings. in many cases a building has 1 electricity and 1 gas meter, but sometimes a building has for instance two electricity meters.

 

What I want to do with this data is:

1. sum up the amount of electricity used in an hour with the gas used in an hour. Herefor I'm looking for the maximum use of electricity in every hour of the year, which i will mutiply times four. And I am looking for the maximum amount of gas used in every hour of the year. I have made a new column in my datasheet in which I have converted quarters into hours (so 0:00, 0:15, 0:30 and 0:45 are now all 0:00). Because I have 200 different meters I have made a new column in which I have grouped the name of the meter, the date and the timestamp (full hours).  Based upon this data I have created a new table in which I have used the function groupby so that I have left 200 (meters) x 8760 (hours per year) unique datapoints.

This table I want to expend with the max value for electricity consumption per hour and the max value for gas consumption per hour.

 

This looks as following:

datasheet

ProductDateTimeConsumptionTimestamp (hour)New measure
Electricity00101-01-202100:000,5100:00Electricity001 01-01-2021 00:00
Electricity00101-01-202100:150,5800:00Electricity001 01-01-2021 00:00
Electricity00101-01-202100:300,6200:00Electricity001 01-01-2021 00:00
Electricity00101-01-202100:450,5300:00Electricity001 01-01-2021 00:00
Electricity001...............
Electricity002...............
Gas00101-01-202100:002,300:00Gas001 01-01-2021 00:00
Gas00101-01-202101:003,401:00Gas001 01-01-2021 01:00

 

What I want to create in a new table looks like:

Product date timestamp hourlyMax consumption
Electricity001 01-01-2021 00:000,62
Electricity001 01-01-2021 01:00...
Electricity001 01-01-2021 02:00...
......
Gas001 01-01-2021 00:002,3
Gas001 01-01-2021 01:003,4
... 
... 

 

2. My second database contains the data from which I know which meter belongs to which building. Based upon this knowledge I want to expand my former new table with the data of which building belongs to a specific meter. So the table looks like this: This is what I have allready build, lacking the maximum value 🙂

Product date timestamp hourlyMax consumptionBuildingNew unique measure 
Electricity001 01-01-2021 00:000,62Building001Building001 01-01-2021 00:00 
Electricity001 01-01-2021 01:000,8Building001Building001 01-01-2021 01:00 
Electricity001 01-01-2021 02:00...Building001Building 01-01-2021 02:00 
............ 
Gas001 01-01-2021 00:002,3Building001Building001 01-01-2021 00:00 
Gas001 01-01-2021 01:003,4Building001Building001 01-01-2021 01:00 
... Building002Building002 ... 
... ...Etc... 

 

From this table I have created a new table in which I used the groupby formula another time but now to create new unique variables containing the name of the building and the date and hourly timestamp (Building001 01-01-2021 00:00, etc..) In this table I want to sum up the max consumption values for electricity and gas per building.

So for instance:

New unique measureTotal consumption
Building001 01-01-2021 00:002,92
Building001 01-01-2021 01:004,20
Building 01-01-2021 02:00...
......
Building001 01-01-2021 00:002,3
Building001 01-01-2021 01:003,4
Building002 ......
Etc......

 

I hope this clarifies what I am trying to do with the data.

Thanks in advance,

Rinto

v-yalanwu-msft
Community Support
Community Support

Hi, @Rinto ;

You could create a measure.

max = CALCULATE(MAX('Table'[Value]),FILTER(ALLSELECTED('Table'),[Unique key]=MAX([Unique key])))

The final show:

vyalanwumsft_0-1653532542379.png


Best Regards,
Community Support Team _ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-yalanwu-msft for your reaction

 

I am looking for a query with which I can build a new column, because after this new column is created i want to sum up two datastreams to a new unique datacolumn.

For example Frank and Theo live in the same house (adress). After I have found the max measure for a date and time stamp with the name Frank and the same for Theo. With the next step I want to sum up the max value for Frank and Theo at the exact samen date and time stamp, using a new unique code in which the date and time stamp are used in combination with the adress of there home.

 

Thanks,

Rinto

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.