cancel
Showing results for 
Search instead for 
Did you mean: 

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

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

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

Dashboard in a day with date

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!

Power BI Fabric Summit Carousel

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