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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.