cancel
Showing results for
Did you mean:

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

New Member

## How to calculate the number of people waiting in a queue

Dear Power BI community,

I have the following problem and I can not find my way out...

For each sequence number, I have the number of people that enter the system and the number of people that the system has the capacity to process (output), so if input<output then the queue is ZERO, else the amount of the queue will be Queue(n-1) + Input - Output, as the print shows below.

I need to replicate this excel calculation in a DAX function to calculate the number of people waiting in the queue.

Any idea if it is feasible and how to proceed?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

I think there is a simple w<ay to write it but I did not find it.

Queue2 =
if(Feuil3[Input]>Feuil3[Ouput],Feuil3[Input]-Feuil3[Ouput],0)

and after I wrote this measure

queue =
VAR activseq =
SELECTEDVALUE ( Feuil3[Sequence] )
VAR prevseq = activseq - 1
VAR preval =
LOOKUPVALUE ( Feuil3[Queue2], Feuil3[Sequence], prevseq )
VAR calc =
MAX ( Feuil3[Input] ) - MAX ( Feuil3[Ouput] )
VAR result =
IF (
SELECTEDVALUE ( Feuil3[Input] ) > SELECTEDVALUE ( Feuil3[Ouput] ),
SELECTEDVALUE ( Feuil3[Input] ) + preval
- SELECTEDVALUE ( Feuil3[Ouput] ),
0
)
RETURN
result

Final result is this. I hope it helps.

Anonymous
Not applicable

Hi

I think there is a simple w<ay to write it but I did not find it.

Queue2 =
if(Feuil3[Input]>Feuil3[Ouput],Feuil3[Input]-Feuil3[Ouput],0)

and after I wrote this measure

queue =
VAR activseq =
SELECTEDVALUE ( Feuil3[Sequence] )
VAR prevseq = activseq - 1
VAR preval =
LOOKUPVALUE ( Feuil3[Queue2], Feuil3[Sequence], prevseq )
VAR calc =
MAX ( Feuil3[Input] ) - MAX ( Feuil3[Ouput] )
VAR result =
IF (
SELECTEDVALUE ( Feuil3[Input] ) > SELECTEDVALUE ( Feuil3[Ouput] ),
SELECTEDVALUE ( Feuil3[Input] ) + preval
- SELECTEDVALUE ( Feuil3[Ouput] ),
0
)
RETURN
result

Final result is this. I hope it helps.

Announcements

#### Power BI Monthly Update - November 2023

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

#### Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

#### Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

#### The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors