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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Bit2021
Frequent Visitor

Help to calculate growth rate per hour and day

I have a table like the below:

Bit2021_0-1628700542408.png

 The value of "Amount of records ..." is the last number of records inside the table.

Note: I have a job that runs a "select count(*) from table1" query and then inserts it into a table with date and time.

 

Now, I want to calculate the growth rate per hour and day like the below screenshot:

 

Bit2021_1-1628700901804.png

 

How can I do this with Power BI? 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Bit2021 
In this case, you need to create datetime column otherwise the calculate needs very complex filter condition because the time and date are separated. See pbix if needed.

Vpazhenmsft_1-1629078678256.png

1. DateTime = CONCATENATE([Date],CONCATENATE(" ",[Time]))

2. New =

var previous_datetime = CALCULATE(MAX([DateTime]),FILTER('Table',[DateTime]<EARLIER('Table'[DateTime])))
Return IF([DateTime]=MINX(ALL('Table'),[DateTime]),[Records]-3050,[Records]-CALCULATE(MAX([Records]),FILTER('Table',[DateTime]=previous_datetime)))
3. Growth =
var previous_datetime = CALCULATE(MAX([DateTime]),FILTER('Table',[DateTime]<EARLIER('Table'[DateTime])))
Return IF([DateTime]=MINX(ALL('Table'),[DateTime]),[New]/3050,[New]/CALCULATE(MAX('Table'[Records]),FILTER('Table',[DateTime]=previous_datetime)))
 
 
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@Bit2021 
In this case, you need to create datetime column otherwise the calculate needs very complex filter condition because the time and date are separated. See pbix if needed.

Vpazhenmsft_1-1629078678256.png

1. DateTime = CONCATENATE([Date],CONCATENATE(" ",[Time]))

2. New =

var previous_datetime = CALCULATE(MAX([DateTime]),FILTER('Table',[DateTime]<EARLIER('Table'[DateTime])))
Return IF([DateTime]=MINX(ALL('Table'),[DateTime]),[Records]-3050,[Records]-CALCULATE(MAX([Records]),FILTER('Table',[DateTime]=previous_datetime)))
3. Growth =
var previous_datetime = CALCULATE(MAX([DateTime]),FILTER('Table',[DateTime]<EARLIER('Table'[DateTime])))
Return IF([DateTime]=MINX(ALL('Table'),[DateTime]),[New]/3050,[New]/CALCULATE(MAX('Table'[Records]),FILTER('Table',[DateTime]=previous_datetime)))
 
 
Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@Bit2021 

 

Create the following columns, and change the decimal value to percent in the format.

 

New = IF([Date]=MINX(ALL('Table'),[Date]),
[Records]-5100,
[Records]-CALCULATE(MAX([Records]),FILTER('Table',[Date]=EARLIER('Table'[Date])-1)))
 
Growth = IF([Date]=MINX(ALL('Table'),[Date]),[New]/5100,[New]/CALCULATE(MAX('Table'[Records]),FILTER('Table',[Date]=EARLIER([Date])-1)))
 
Vpazhenmsft_0-1628836984972.png

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

Thanks for your reply, I have a time column like the below, which change should id do in your code?

 

Bit2021_0-1628875655290.png

the default value = 3050

ex: 3341-3050 = 291

3874 - 3341 = 533

....

Greg_Deckler
Community Champion
Community Champion

@Bit2021 Seems like a variation on MTBF. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for your reply. I use the below method but I think I couldn't understand it very well and I received the wrong result.

 

Bit2021_0-1628758190352.png

Just for clarifying, I show my sample request in Excel:

Bit2021_1-1628758271246.png

I have a table (white background) and my calculate columns are yellow background.

New records = Current - Previous 

Ex: 5100-5214 = 114

 

Growth rate:

Bit2021_2-1628758489067.png

((5214-5100)/5100) * 100 = 2.23

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.