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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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

 

ricardobresolin_1-1666729015610.png

 

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?

Many thanks in advance for your help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi

 

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

Anyway, first I added a column to your table. Input-Output

 

Queue2 =
if(Feuil3[Input]>Feuil3[Ouput],Feuil3[Input]-Feuil3[Ouput],0)
JamesFr06_0-1666736861121.png

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.
JamesFr06_1-1666736927817.png

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi

 

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

Anyway, first I added a column to your table. Input-Output

 

Queue2 =
if(Feuil3[Input]>Feuil3[Ouput],Feuil3[Input]-Feuil3[Ouput],0)
JamesFr06_0-1666736861121.png

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.
JamesFr06_1-1666736927817.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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