Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

First pass yield???

Hello everyone, I need help from you at how can I get the % pass that occurred the first time for each ID? Considering all the fields in the table. ID Last Transaction Result Start t...
  • Anonymous's avatar
    Anonymous
    5 years ago
    // T is the table from your post...
    
    [Pass 1st Time (%)] = 
    var IDsWithEarliestDates = 
    // First, get for all visible ID's
    // their minimum start times VISIBLE
    // in the current context(!!!).
        ADDCOLUMNS(
            DISTINCT( T[ID] ),
            "@MinStartTime",
                CALCULATE(
                    MIN( T[Start Time] )
                )
        )
    var CountOfIDsWherePassIsFirst = 
    // Calculate the number of ID's
    // where the result for the first
    // visible date, as calculated above,
    // is "pass."
        CALCULATE(
            DISTINCTCOUNT( T[ID] ),
            TREATAS(
                IDsWithEarliestDates,
                T[ID],
                T[Start Time]
            ),
            KEEPFILTERS( T[Result] = "Pass" )
        )
    var CountOfAllVisibleIDs =
    // Get the number of all visible ID's.
        DISTINCTCOUNT( T[ID] )
    var Result = 
        DIVIDE(
            CountOfIDsWherePassIsFirst,
            CountOfAllVisibleIDs
        )
    RETURN
        Result

    Be careful - this formula is sensitive to all filters you put on the table, meaning it respects them all, so the calculation above is carried out within the visible set of ID's with all the restricting filters.