Forum Discussion

DaanBos's avatar
DaanBos
Frequent Visitor
2 years ago

Count occurrences until certain value

Dear all,

 

I want to count the iterations required to get an amount of 50 throughput. Below is the code I created. But the problem now is that it gives the same value in the entire column. Does anyone know the answer?

CountIt = 
VAR RandomIterations = 0
VAR TotalThroughput = 0
VAR ThroughputNeeded = 50
VAR RandomThroughput = CALCULATE(
    VALUES('Iterties'[Throughput]),
    FILTER(
        'Iterties',
        'Iterties'[Iteratie] = EARLIER(Monte_Carlo_Simulation[Random]) --ROUND(RANDBETWEEN(1, COUNTROWS(Iterties)), 0)--
    )
)
VAR UpdatedTotalThroughput = TotalThroughput + RandomThroughput

RETURN
IF(
    UpdatedTotalThroughput < ThroughputNeeded,
    COUNTAX(VALUES('Iterties'[Iteratie]), 1),
    0
)

 

Greets,

Daan

2 Replies