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
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
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.