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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Nantook
New Member

Looping in a Measure

Hello! I'm fairly new to Power BI and was hoping for assistance.

 

I have a data set that tracks the number of calls per hour for a service desk as well as the number of agents that are working that hour. I've got a visual of a Line and Stacked Column chart that correctly shows the calls per hour along the x-axis and the number of agents on duty is shown as the line value.

 

What I am trying to do is add a second line value to the graph showing the recommended number of agents required. I've added several measures to assist with calculating the number of agents but i've ran into an issue. The formula to calculate the agents required is being converted from an existing VBA formula:

 

 

A_n = 1
SumA_k = 0

For k = agentStep To 0 Step -1 A_k = A_n * k / Intensity SumA_k = SumA_k + A_k A_n = A_k Next k

 

 

Is there any way I can convert something like this to a measure? Or is this something that will have to be calculated on the excel spreadsheet first with VBA and then imported into Power BI? The problem is that agentStep is not a static amount or I would just hardcode the loop and I couldn't find any way to loop within a measure to calculate a value like this.

 

Thanks for any help!

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@Nantook,

 

See the discussion in link below.

https://community.powerbi.com/t5/Desktop/Ahead-Moving-Average-Circle-Reference/td-p/254814

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

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.