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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PBI_newuser
Post Prodigy
Post Prodigy

How to display the groups that contains certain subgroup?

Hi,

How to display only the Part Number that have subgroup of suffix "-09" (highlight in yellow) but do not include those with only one subgroup of suffix "-09" (highlight in pink)?

PBI_newuser_0-1611814666085.png

 

1 ACCEPTED SOLUTION

Hi, @PBI_newuser 

 

I am sorry for late reply. You may try replacing 'ALL' with 'ALLSELECTED' in measures like below.

 

Visual control2 = 
SWITCH(
    SELECTEDVALUE(Slicer[Type]),
    "A",
    IF(
        COUNTROWS(
            FILTER(
                ALLSELECTED('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="09"
            )
        )>0,
        1,0
    ),
    "B",
    IF(
        COUNTROWS(
            FILTER(
                ALLSELECTED('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="07"
            )
        )>0,
        1,0
    ),
    "C",
    IF(
        COUNTROWS(
            FILTER(
                ALLSELECTED('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="10"
            )
        )>0,
        1,0
    ),
    1
)

 

 

Best Regards

Allan

 

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

10 REPLIES 10
v-alq-msft
Community Support
Community Support

Hi, @PBI_newuser 

 

Based on your description, I created data to reproduce your scenario, The pbix file is attached in the end.

Table:

g1.png

 

You may create a measure as below.

Visual control = 
    IF(
        CALCULATE(
            DISTINCTCOUNT('Table'[SubGroup]),
            ALLEXCEPT('Table','Table'[PartNumber])
        )>1&&
        COUNTROWS(
            FILTER(
               ALLEXCEPT('Table','Table'[PartNumber]),
               RIGHT([SubGroup],2)="09"
            )
        )>0,
        1,0
    )

 

Then you may put the measure in the visual level filter to filter the result.

g2.png

 

Best Regards

Allan

 

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

Hi @v-alq-msft , when i tried on larger dataset, it doesn't work. Please see the data here.

Is it possible to have a slicer "Type", if select "Type A", then those parts with suffix of "-09" show up, if select "Type B", then those parts with suffix of "-08" show up.

 

PBI_newuser_0-1612182662640.png

 

Hi, @PBI_newuser 

 

I can not access the data you provided. I modified data to reproduce your scenario. The pbix file is attached in the end.

Table:

a1.png

 

Test:

a2.png

 

You may modify the measure like below.

Visual control = 
    IF(
        CALCULATE(
            DISTINCTCOUNT('Table'[SubGroup]),
            ALLEXCEPT('Table','Table'[PartNumber])
        )>1&&
        COUNTROWS(
            FILTER(
               ALLEXCEPT('Table','Table'[PartNumber]),
               RIGHT([SubGroup],2)="09"
            )
        )>0,
        IF(
            OR(
                "A" in DISTINCT(Test[Type])&&RIGHT(SELECTEDVALUE('Table'[SubGroup]),2)="09",
                "B" in DISTINCT(Test[Type])&&RIGHT(SELECTEDVALUE('Table'[SubGroup]),2)="08"
            ),
        1,0
        )
    )

 

Result:

a3.pnga4.png

 

Best Regards

Allan

 

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

 

Hi @v-alq-msft , I have updated the data URL here.

I would like to see the group of part numbers with suffix of "-09" when I select Type A.

For example, when I select Type A, the highlighted groups in the screenshot should show up.

 

PBI_newuser_1-1612232734220.png

 

 

Hi, @PBI_newuser 

 

You may create a new table like below. The pbix file is attached in the end.

Slicer:

b1.png

 

Then you may modify the measures as below. When 'A' is selected, items ending with '09' display. When 'B' is selected, items with '07' display. When 'C' is selected, items with '10' display.

Visual control = 
SWITCH(
    SELECTEDVALUE(Slicer[Type]),
    "A",
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[PartNumber]=MAX('Table'[PartNumber])&&
                RIGHT([SubGroup],2)="09"
            )
        )>0,
        1,0
    ),
    "B",
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[PartNumber]=MAX('Table'[PartNumber])&&
                RIGHT([SubGroup],2)="07"
            )
        )>0,
        1,0
    ),
    "C",
    IF(
        COUNTROWS(
            FILTER(
                ALL('Table'),
                'Table'[PartNumber]=MAX('Table'[PartNumber])&&
                RIGHT([SubGroup],2)="10"
            )
        )>0,
        1,0
    ),
    1
)
Visual control2 = 
SWITCH(
    SELECTEDVALUE(Slicer[Type]),
    "A",
    IF(
        COUNTROWS(
            FILTER(
                ALL('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="09"
            )
        )>0,
        1,0
    ),
    "B",
    IF(
        COUNTROWS(
            FILTER(
                ALL('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="07"
            )
        )>0,
        1,0
    ),
    "C",
    IF(
        COUNTROWS(
            FILTER(
                ALL('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="10"
            )
        )>0,
        1,0
    ),
    1
)

 

Result:

b2.pngb3.pngb4.png

 

Best Regards

Allan

 

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

Hi @v-alq-msft , it works if there is no filter is selected.

Is it possible to include this criteria in measure as user may select different slicers to view different data?

 

Filter of last 12 months:

PBI_newuser_1-1612257837937.png

No filter: 

PBI_newuser_2-1612257848554.png

 

Hi, @PBI_newuser 

 

I am sorry for late reply. You may try replacing 'ALL' with 'ALLSELECTED' in measures like below.

 

Visual control2 = 
SWITCH(
    SELECTEDVALUE(Slicer[Type]),
    "A",
    IF(
        COUNTROWS(
            FILTER(
                ALLSELECTED('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="09"
            )
        )>0,
        1,0
    ),
    "B",
    IF(
        COUNTROWS(
            FILTER(
                ALLSELECTED('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="07"
            )
        )>0,
        1,0
    ),
    "C",
    IF(
        COUNTROWS(
            FILTER(
                ALLSELECTED('data'),
                'data'[PartNumber]=MAX('data'[PartNumber])&&
                RIGHT([SubGroup],2)="10"
            )
        )>0,
        1,0
    ),
    1
)

 

 

Best Regards

Allan

 

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

Hi @v-alq-msft , it works!!!! Thank you so much for all your help! Truly appreciate it! 😀

amitchandak
Super User
Super User

@PBI_newuser ,

Create  a measure

calculate([meausre], filter(Table, right(Table[part_number],2) ="09")

 

Hi @amitchandak , could you share how to do it?

Here's the Sample.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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