Forum Discussion

BartvDonkelaar's avatar
BartvDonkelaar
Frequent Visitor
3 years ago
Solved

Measure combining filter and group by (or similar function)

Hello,   I have a table containing the following columns: - datetime - ID - eventname - delta time between datetime and now (calculated column in PowerQuery)   Example: datetime ID even...
  • BartvDonkelaar's avatar
    BartvDonkelaar
    3 years ago

    Hi Ashish_Mathur ,

     

    When I try this measure, I get an error when entering the FilterExpression. Here 

    [DaysAgo]>=120&&[Event]="Incomplete1"&&[count]>=10

    Is not recognized. The message 'Cannot find name ...' appears.

     

    COUNTROWS(
        FILTER(
            VALUES(
                table[ID]
            ),
            table[DaysAgo] <=120 &&
            table[eventname]="Incomplete1" &&
            COUNTROWS(
                table
            ) >= 10
        )
    )

    I think this is because the function 'VALUES' within the filter only relates to the [ID] column of the table, so this is the only table that is recognized to use in the FilterExpression.

     

    What I tried myself is the following:

    1. Filtering for DaysAgo and eventname is succesful.

    2. Grouping by ID (using SUMMARIZE or SUMMARIZECOLUMNS) is also succesfull, only when I start with this step the DaysAgo information is lost because of the grouping

    3. When applying the filter first, I cannot seem to refer to the newly generated filtered table.

     

    This got me thinking.. and instead of generating a measure for the filters I generated a new table. Here I applied the same logic as in the measure, only resulting in a table. This table as turned out could be used in the SUMMARIZECOLUMNS function. So now I have my column with filters and grouping! 🙂

     

    Final filter table:

    _Incompmlete1Filter = 
    FILTER(
        table,
        table[eventname] = "Incompmlete1" &&
        table[DaysAgo] <= 120
    )

     Final count table:

    _Incomplete1Count = 
    SUMMARIZECOLUMNS(
        _Incompmlete1Filter[ID],
        _Incompmlete1Filter[eventname],
        "Count",
        COUNT(
            _Incompmlete1Filter[eventname]
        )
    )

     

    Thanks for thinking along!

     

    Kind regards,

     

    Bart