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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Learner_SG
Helper IV
Helper IV

Power BI table sum

Hi , I have a condition in which I need to calculate the usage on hourly basis. To make it easier I will explain with a table.

hourusage
12
13
14
23
24
33
36
46
41

I need to come up with a condition where I need to calculate the hourly basis usage. So for hour 1 - the sum value should be 9 ,2 should be 7 and so on. So for this purpose,how should I proceed? This data has to be used for a calculation later. So I should proceed to create a caclulated column/table?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Learner_SG ,

 

1. Here are many methods to calculate the sum.

 

  • Change the summarize type ——Hour:Don't summarize ; Usage: Sum:

Eyelyn9_1-1646288415042.png

  • Create a measure 

 

Measure = CALCULATE(SUM('Table'[usage]),FILTER('Table',[hour]=MAX('Table'[hour])))  
//or
//CALCULATE(SUM('Table'[usage]),ALLEXCEPT('Table','Table'[hour]))

 

  • Create a column:

 

Column = CALCULATE(SUM('Table'[usage]),FILTER('Table',[hour]=EARLIER('Table'[hour])))  
// or 
//CALCULATE(SUM('Table'[usage]),ALLEXCEPT('Table','Table'[hour]))  

 

  • Create a new table: 

 

New Table = SUMMARIZE('Table','Table'[hour],"total usage",SUM('Table'[usage]))

 

 

Eyelyn9_4-1646288714510.pngEyelyn9_3-1646288703581.png   Eyelyn9_2-1646288691311.png

 

2.  if I want to narrow it down for each day and hours, how should I modify the query?

What does "narrow down" mean? Can you please share more detail information to help us clarify your scenario?

 

 

Best Regards,
Eyelyn Qin
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

8 REPLIES 8
Anonymous
Not applicable

Hi @Learner_SG ,

 

Hope this can help:

Measure = CALCULATE(SUM('Table'[usage]),FILTER('Table',[Date]=MAX('Table'[Date])&& [hour]=MAX('Table'[hour])))  
//or
//CALCULATE(SUM('Table'[usage]),ALLEXCEPT('Table','Table'[Date],'Table'[hour]))

Output:

Eyelyn9_0-1647565537434.png

 

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

Anonymous
Not applicable

Hi @Learner_SG ,

 

1. Here are many methods to calculate the sum.

 

  • Change the summarize type ——Hour:Don't summarize ; Usage: Sum:

Eyelyn9_1-1646288415042.png

  • Create a measure 

 

Measure = CALCULATE(SUM('Table'[usage]),FILTER('Table',[hour]=MAX('Table'[hour])))  
//or
//CALCULATE(SUM('Table'[usage]),ALLEXCEPT('Table','Table'[hour]))

 

  • Create a column:

 

Column = CALCULATE(SUM('Table'[usage]),FILTER('Table',[hour]=EARLIER('Table'[hour])))  
// or 
//CALCULATE(SUM('Table'[usage]),ALLEXCEPT('Table','Table'[hour]))  

 

  • Create a new table: 

 

New Table = SUMMARIZE('Table','Table'[hour],"total usage",SUM('Table'[usage]))

 

 

Eyelyn9_4-1646288714510.pngEyelyn9_3-1646288703581.png   Eyelyn9_2-1646288691311.png

 

2.  if I want to narrow it down for each day and hours, how should I modify the query?

What does "narrow down" mean? Can you please share more detail information to help us clarify your scenario?

 

 

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

@Anonymous  Is there any other way for calculation of the usage ,because it worked fine earlier. now my data is growing bigger and the number of rows are higher and it causes power bi to have slower performance.

@Anonymous , its the continuation of the question that I had asked previousl,becuase I am running into error now.

2.  if I want to narrow it down for each day and hours, how should I modify the query?

What does "narrow down" mean? Can you please share more detail information to help us clarify your scenario?

What I mean is that I need to select the sum of usage for each hour in a DAY . now what happens is that it sums up all the usage of each hours from different days  which is not I want. Could help me on it?

 

So assuming you have a Date column as well, try this calculated column formula

=calculate(sum(Data[usage]),filter(data,data[date]=earlier(data[date])&&data[hour]=earlier(data[hour])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Anonymous , I was able to solve the issue .Thanks a lot.  The 2nd question also got resolved.

Learner_SG
Helper IV
Helper IV

thanks @amitchandak , if I want to narrow it down for each day and hours, how should I modify the query?

amitchandak
Super User
Super User

@Learner_SG ,

new column =  sumx(filter(Table,[Hour] = earlier([Hour]) ), [Usage])

 

or

a new measure

new measure =  sumx(filter(allselected(Table),Table[Hour] = max(Table[Hour]) ), Table[Usage])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.