Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Missing filter option after grouping

Hello everyone, I have a table with several deliveries from different suppliers and information on how punctual the delivery was. I would now like to calculate the average per supplier for on-time d...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Anonymous 

    First, you'll need to create a new table with the following:

    Use the following DAX expression to create a category measure:

    category =
    VAR _table =
        SUMMARIZE (
            'Table',
            'Table'[Supplier],
            'Table'[Order Number],
            "On time dilivery",
                ( SUM ( 'Table'[OTD Rate] ) / 100 ) * 'Table'[Order Number]
        )
    VAR _table2 =
        ADDCOLUMNS (
            SUMMARIZE (
                _table,
                'Table'[Supplier],
                "average",
                    VAR aa =
                        SUMX (
                            FILTER ( _table, 'Table'[Supplier] = EARLIER ( 'Table'[Supplier] ) ),
                            [On time dilivery]
                        )
                    VAR _total =
                        SUMX (
                            FILTER ( _table, 'Table'[Supplier] = EARLIER ( 'Table'[Supplier] ) ),
                            'Table'[Order Number]
                        )
                    VAR _average = aa / _total
                    RETURN
                        CEILING ( _average * 100, 1 )
            ),
            "category", IF ( [average] >= 70, "Good", "Critical" )
        )
    RETURN
        MAXX (
            FILTER ( _table2, 'Table'[Supplier] = SELECTEDVALUE ( 'Table'[Supplier] ) ),
            [category]
        )
    

    Next, create a count measure:

    Count1 =
    COUNTROWS (
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[Supplier], "category", [category] ),
            [category] = SELECTEDVALUE ( 'Table 3'[category] )
        )
    )
    

    Use the category and count1 metrics as follows:

    Changing the date selected by the slicer counts dynamically:

     

    I've provided the PBIX file used this time below.

     

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.