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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

conditional count

Hello all,

I'm newbie to PowerBI and I need the comunity help. 

 

I have a table with 3 columns. The first column is "days" of July, the second column, the "hour" of a day when the temprature is recorderd and the third column "temperature" for each hour of a day.
I would like to count the number of rows on the"hour" column till the highest "tempreature" in reached for each day.

In other words I have to find out :

  1. The maximum tempreature in each day.
  2. At what time (hour) the temprature reaches its maximum, (count the number of rows on the hours column till the maximum temperature).
  3. Since the temprature was not recorded for all the hours of each day, I need to know the total number of datapoints (the number of records) for each day. 

Please find below the data.

Thanks

Q007

DayHourTemperature
17015.49
17114.72
17214.04
17814.76
17916.91
171018.58
171120.18
171221.57
171322.8
171423.84
171524.58
171624.99
171724.24
171823.92
171923.48
172022.94
172121.44
172219.91
172319.03
18018.53
18116.39
18214.45
18312.73
181019.8
181121.21
181220.49
181319.68
181419.94
181520.95
181618.63
181717.71
181816.58
181915.39
182014.56
182113.49
182212.59
182312.69
19611.28
19712.17
19813.08
19914.41
191015.59
191115.73
191215.5
191314.8
191414.4
191513.51
191612.78
191712.36
191812.29
191912.65
192012.82
192112.41
192211.87
192311.81
20011.92
20112.11
20212.37
20312.55
20412.17
20511.17
20611.99
20712.71
20813.94
20916.19
201018.24
201621.3
201721.95
201821.13
201921.1
202020.56
202119.26
202218.71
202317.93
21017.22
21117.01
21216.28
21315.46
21414.7
21514.09
21613.93
21715.04
21817.26
21919.16
211020.43
211121.64
211222.65
211323.57
211424.32
211524.87
212120.6
212217.92
212316.34
22015.14
22114.19
22213.52
22312.81
22411.96
22511.03
22610.78
22714.29
221022.53
221124.5
221226.14
221327.48
221428.41
221529.13
221629.61
221730.02
221830.1
221929.48
222028.14
222124.45
222222.01
222320.94
23019.69
23118.71
23217.89
23316.57
23415.58
23514.8
23614.43
23717.86
23822.07
23925.09
231027.29
231433.04
231533.76
231634.15
231734.34
231834.26
231933.59
232032.11
232129.8
232227.79
232325.78
24024.17
24122.37
24221.16
241023.57
241127.68
241229.26
241329.15
241429.82
241529.85
241629.44
241728.47
241826.85
241924.72
242021.18
242117.77
242216.79
242316.2

 

1 ACCEPTED SOLUTION

@Anonymous 

 

Try these MEASURES

File attached as well with your sample data

 

Max_Temp = Max(Table1[Temperature])
DataPoints_Till_MaxTemp =
VAR maxtemp = [Max_Temp]
VAR MyHour =
    CALCULATE ( MIN ( Table1[Hour] ), Table1[Temperature] = maxtemp )
RETURN
    COUNTROWS ( FILTER ( Table1, Table1[Hour] <= MyHour ) )
Total Data Points = Count(Table1[Temperature])


 

View solution in original post

6 REPLIES 6
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

What is your expected output with this sample data?

Anonymous
Not applicable

Hello,

My expection is to know:

  • The max temperature in each given day.
  • How many datapoints have been counted to get to the max temperature in each day.
  • How many datapoints we have for each day.

Best

Q007

@Anonymous 

 

Try these MEASURES

File attached as well with your sample data

 

Max_Temp = Max(Table1[Temperature])
DataPoints_Till_MaxTemp =
VAR maxtemp = [Max_Temp]
VAR MyHour =
    CALCULATE ( MIN ( Table1[Hour] ), Table1[Temperature] = maxtemp )
RETURN
    COUNTROWS ( FILTER ( Table1, Table1[Hour] <= MyHour ) )
Total Data Points = Count(Table1[Temperature])


 

Anonymous
Not applicable

Sure,

I have posted another question. Did you see it? This time I have two extra columns, country and city.

I would like to do the same thing as we did before but this time spit by town and country.

 

Best

Q

Anonymous
Not applicable

Thanks a lot
Now I have a table with 5 columns. The first column is "Country", the second column is "Town", third is "Days" of July, the fourth column, the "Hour" of a day when the temperature is recorded and the fifth column "temperature" for each hour of a day.
I would like to count the number of rows on the “hour" column till the highest "temperature" in reached for each day in any city and country.
My expectations are to know:
1. The max temperature in each given day, by town by country.
2. How many data points have been counted to get to the max temperature in each day?
3. How many data points we have for each day?
BestQ007

CountryTownDayHourTemperature
GermanyFrankfurt17015.49
GermanyFrankfurt17114.72
GermanyFrankfurt17214.04
GermanyFrankfurt17814.76
GermanyFrankfurt17916.91
GermanyFrankfurt171018.58
GermanyFrankfurt171120.18
GermanyFrankfurt171221.57
GermanyFrankfurt171322.8
GermanyFrankfurt171423.84
GermanyFrankfurt171524.58
GermanyFrankfurt181618.63
GermanyFrankfurt181717.71
GermanyFrankfurt181816.58
GermanyFrankfurt181915.39
GermanyFrankfurt182014.56
GermanyFrankfurt182113.49
GermanyFrankfurt182212.59
GermanyFrankfurt182312.69
GermanyFrankfurt19611.28
GermanyFrankfurt19712.17
GermanyFrankfurt19813.08
GermanyFrankfurt19914.41
GermanyFrankfurt191015.59
GermanyFrankfurt191115.73
GermanyFrankfurt191215.5
GermanyFrankfurt191314.8
GermanyFrankfurt191414.4
GermanyFrankfurt191513.51
GermanyFrankfurt20511.17
GermanyFrankfurt20611.99
GermanyFrankfurt20712.71
GermanyFrankfurt20813.94
GermanyFrankfurt20916.19
GermanyFrankfurt201018.24
GermanyFrankfurt201621.3
GermanyFrankfurt201721.95
GermanyFrankfurt201821.13
GermanyFrankfurt201921.1
GermanyFrankfurt202020.56
GermanyFrankfurt202119.26
GermanyFrankfurt202218.71
GermanyFrankfurt202317.93
GermanyFrankfurt21017.22
GermanyFrankfurt21117.01
GermanyFrankfurt21216.28
GermanyFrankfurt21315.46
GermanyFrankfurt21414.7
GermanyFrankfurt21514.09
GermanyFrankfurt21613.93
GermanyFrankfurt21715.04
GermanyFrankfurt21817.26
GermanyFrankfurt21919.16
GermanyFrankfurt221022.53
GermanyFrankfurt221124.5
GermanyFrankfurt221226.14
GermanyFrankfurt221327.48
GermanyFrankfurt221428.41
GermanyFrankfurt221529.13
GermanyFrankfurt221629.61
GermanyFrankfurt221730.02
GermanyFrankfurt221830.1
GermanyFrankfurt221929.48
GermanyFrankfurt222028.14
GermanyFrankfurt222124.45
GermanyFrankfurt222222.01
GermanyFrankfurt222320.94
GermanyFrankfurt23019.69
GermanyFrankfurt23118.71
GermanyFrankfurt23217.89
GermanyFrankfurt23316.57
GermanyFrankfurt23415.58
GermanyFrankfurt23514.8
GermanyFrankfurt23614.43
GermanyFrankfurt23717.86
GermanyFrankfurt23822.07
GermanyFrankfurt23925.09
GermanyFrankfurt231027.29
GermanyFrankfurt231433.04
GermanyFrankfurt231533.76
GermanyFrankfurt231634.15
GermanyFrankfurt231734.34
GermanyFrankfurt231834.26
GermanyFrankfurt241229.26
GermanyFrankfurt241329.15
GermanyFrankfurt241429.82
GermanyFrankfurt241529.85
GermanyFrankfurt241629.44
GermanyFrankfurt241728.47
GermanyFrankfurt241826.85
GermanyFrankfurt241924.72
GermanyFrankfurt242021.18
GermanyFrankfurt242117.77
GermanyFrankfurt242216.79
GermanyFrankfurt242316.2
UKLondon10012.4
UKLondon10111.8
UKLondon10211.2
UKLondon10811.8
UKLondon101620
UKLondon101719.4
UKLondon101819.1
UKLondon101918.8
UKLondon102018.4
UKLondon102117.2
UKLondon102215.9
UKLondon102315.2
UKLondon11014.8
UKLondon11113.1
UKLondon11211.6
UKLondon11310.2
UKLondon111015.8
UKLondon111117
UKLondon111216.4
UKLondon111315.7
UKLondon111416
UKLondon111516.8
UKLondon111614.9
UKLondon111714.2
UKLondon111813.3
UKLondon121610.2
UKLondon12179.9
UKLondon12189.8
UKLondon121910.1
UKLondon122010.3
UKLondon12219.9
UKLondon12229.5
UKLondon12239.4
UKLondon1309.5
UKLondon1319.7
UKLondon1329.9
UKLondon13310
UKLondon1349.7
UKLondon1358.9
UKLondon1369.6
UKLondon13710.2
UKLondon13811.2
UKLondon14312.4
UKLondon14411.8
UKLondon14511.3
UKLondon14611.1
UKLondon14712
UKLondon14813.8
UKLondon14915.3
UKLondon141016.3
UKLondon141117.3
UKLondon141218.1
UKLondon141318.9
UKLondon1549.6
UKLondon1558.8
UKLondon1568.6
UKLondon15711.4
UKLondon151018
UKLondon151119.6
UKLondon151220.9
UKLondon151322
UKLondon151422.7
UKLondon151523.3
UKLondon151623.7
UKLondon151724
UKLondon152217.6
UKLondon152316.8
UKLondon16015.8
UKLondon16115
UKLondon16214.3
UKLondon16313.3
UKLondon16412.5
UKLondon16511.8
UKLondon16611.5
UKLondon161627.3
UKLondon161727.5
UKLondon161827.4
UKLondon161926.9
UKLondon162025.7
UKLondon162123.8
UKLondon162222.2
UKLondon162320.6
UKLondon17019.3
UKLondon17117.9
UKLondon17216.9
UKLondon171018.9
UKLondon171122.1
UKLondon171223.4
UKLondon171323.3
UKLondon171423.9
UKLondon171523.9
UKLondon171623.6
UKLondon171722.8
Anonymous
Not applicable

Zubair,

Thanks a lot for your solution. I will let you know if that works on my dataset or not.

Best

Qmars

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.