Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
lena10
New Member

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 delivery and then group this into categories (e.g. ‘Good’ for averages greater than 50). The report view should then show me how many suppliers have their average in which category.
I have already solved the problem by duplicating the table in PowerQuery, grouping it and then adding a new column with the category. Unfortunately, the resulting pie chart in which the suppliers are counted can of course no longer be filtered (e.g. by date of delivery).
The filter option is important, however, as the average changes depending on the time period selected in the report view.
Does anyone have a solution for this?

Thank you very much!

1 ACCEPTED SOLUTION

Hi, @lena10 

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

vjianpengmsft_0-1715843513576.png

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:

vjianpengmsft_1-1715843818985.png

Changing the date selected by the slicer counts dynamically:

vjianpengmsft_2-1715843883090.png

vjianpengmsft_3-1715843899917.png

 

vjianpengmsft_4-1715843925516.png

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.

 

View solution in original post

3 REPLIES 3
v-jianpeng-msft
Community Support
Community Support

Hi, @lena10 

If you need to dynamically change based on your slicer selection, you'll need to create a measure. I created the following sample data:

vjianpengmsft_0-1715649310271.png

First, we need to create an On-Time Delivery Rate (OTD) metric for each supplier:

OTD Rate (%) = 
VAR _Ontime_deliever = SELECTEDVALUE(SupplierDelivery[On-Time Deliveries])
VAR _total_order = SELECTEDVALUE(SupplierDelivery[Total Orders])
RETURN
DIVIDE(_Ontime_deliever, _total_order) * 100

After that we need to create a measure that groups suppliers:

Supplier Category = IF(ISINSCOPE(SupplierDelivery[Supplier]),
SWITCH(
    TRUE(),
    [OTD Rate (%)] > 90, "Excellent",
    [OTD Rate (%)] >= 70 && [OTD Rate (%)] <= 90, "Good",
    [OTD Rate (%)] >= 50 && [OTD Rate (%)] < 70, "Fair",
    "Needs Improvement"
)
)

Put these measures in the table visual:

vjianpengmsft_1-1715649577828.png

Metrics dynamically calculate groupings based on your slicer selections. 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.

 

Thank you for your help!
My data looks more like this, just with even more columns with other information.

lena10_0-1715774196195.png

At the end I would like to have a table or a pie chart showing the number of suppliers that are in the categories with their average. E.g. all with an average >70 are ‘Good’ and all others are ‘Critical’:

lena10_1-1715774747135.png

Normally I would group the data in PowerQuery, then make a new column with the category and then count how many suppliers with this category there are. But then unfortunately my visuals are no longer dynamic and the filters don't work.

I hope this explains the problem a little better.

 

 

Hi, @lena10 

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

vjianpengmsft_0-1715843513576.png

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:

vjianpengmsft_1-1715843818985.png

Changing the date selected by the slicer counts dynamically:

vjianpengmsft_2-1715843883090.png

vjianpengmsft_3-1715843899917.png

 

vjianpengmsft_4-1715843925516.png

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.

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

August Carousel

Fabric Community Update - August 2024

Find out what's new and trending in the Fabric Community.