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