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
Anonymous
Not applicable

Grouping categories by selecting from table visual

I have a table visual that looks something like this:

 

categoryvalue
A3123
B542
C753
D124

 

Basically a category and a corresponding value. I want to be able to, for example, select category A then somehow group all the other categories into an 'Other' category where it's the sum of their values. Or just select all categories I want under 'Other' and group them.

 

From the table vidual, I can't seem to group anything; the option is disabled. Not sure why, but how would I best do this? Preferrably without using measures/calculated columns if possible. 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Here is one way:

1) Create a table using:

Other table.JPGJoin via inactive relationshipJoin via inactive relationship

The create the measures:

 

Sum Value =
CALCULATE (
    SUM ( 'Table'[value] ),
    USERELATIONSHIP ( 'Other Table'[Other category], 'Table'[category] )
)

 

 

 

Other Value =
VAR _All =
    CALCULATE ( SUM ( 'Table'[value] ), ALL ( 'Table'[category] ) )
RETURN
    _All - CALCULATE ( [Sum Value], ALL ( 'Other Table'[Other category] ) )
Totals Measure =
IF (
    SELECTEDVALUE ( 'Other Table'[Other category] ) = "Other",
    [Other Value],
    [Sum Value]
)

 

and the final measure for the visual:

 

Final Measure = 
IF(
   ISFILTERED('Table'[category]), 
    SUMX(ADDCOLUMNS(VALUES('Other Table'[Other category]), "_totals",[Totals Measure]), [_totals]), [Sum Value])

 

To get this:

Other.gif

 

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Here's my solution.

1.Create a new table by entering data.

vstephenmsft_0-1638339069484.png

 

2.Create a measure to calculate the value.

filtered value =
IF (
    MAX ( 'Table (2)'[category] ) = "other",
    SUMX ( ALL ( 'Table' ), [value] )
        - CALCULATE (
            SUM ( 'Table'[value] ),
            FILTER ( 'Table', [category] IN ALLSELECTED ( 'Table'[category] ) )
        ),
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( 'Table', [category] = MAX ( 'Table (2)'[category] ) )
    )
)

 

3.Results.

vstephenmsft_1-1638339148174.pngvstephenmsft_2-1638339155675.png

 

Best Regards,

Stephen Tao

 

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

 

 

PaulDBrown
Community Champion
Community Champion

Here is one way:

1) Create a table using:

Other table.JPGJoin via inactive relationshipJoin via inactive relationship

The create the measures:

 

Sum Value =
CALCULATE (
    SUM ( 'Table'[value] ),
    USERELATIONSHIP ( 'Other Table'[Other category], 'Table'[category] )
)

 

 

 

Other Value =
VAR _All =
    CALCULATE ( SUM ( 'Table'[value] ), ALL ( 'Table'[category] ) )
RETURN
    _All - CALCULATE ( [Sum Value], ALL ( 'Other Table'[Other category] ) )
Totals Measure =
IF (
    SELECTEDVALUE ( 'Other Table'[Other category] ) = "Other",
    [Other Value],
    [Sum Value]
)

 

and the final measure for the visual:

 

Final Measure = 
IF(
   ISFILTERED('Table'[category]), 
    SUMX(ADDCOLUMNS(VALUES('Other Table'[Other category]), "_totals",[Totals Measure]), [_totals]), [Sum Value])

 

To get this:

Other.gif

 

I've attached the sample PBIX file





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Aburar_123
Resolver IV
Resolver IV

Hi,

 

Please find the below solution,

 

I have the data as below,

Aburar_123_1-1638105307978.png

I want to group the city code. DEL is one group and MI, SRH are coming under the group called Other. Below are the steps,

 

Click the three dots corresponding tho the "City code" column then select "New Group" option in the popup list,

Aburar_123_2-1638105480256.png

then, Click on the City code "DEL" and Click Group button at the bottom,

 

Aburar_123_3-1638105559993.png

then click on "Include Other group" check box to create the Other category automatically as like below,

 

 

Aburar_123_0-1638105181670.png

 

Final result is as below,

 

Aburar_123_4-1638105642756.png

 

Please like the solution if it solves your scenario and let me know if you expect anything else.

 

Anonymous
Not applicable

Thanks for the answer. I tried this but unfortunately, end-users can't really do that. I want them to be able to just select the categories they want to display and have all other categories as others.

 

I guess the only way to have it dynamics is to use a measure. It worked for me but I had to use a slicer to select, not click on the table visual categories. 

aj1973
Community Champion
Community Champion

Hi @Anonymous 

I think this should do the work

aj1973_0-1638111206210.png

 

Regards
Amine Jerbi

If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook

Hi,

 

I have just taken reference from @PaulDBrown and created the below single measure,

 

Final Measure =
IF(MAX('Other Table'[Other category])="Other", CALCULATE(SUM('Table'[value]),FILTER(all('Table'),NOT('Table'[category]) in VALUES('Table'[category]))),CALCULATE(SUM('Table'[value]),FILTER('Table','Table'[category] =max('Other Table'[Other category]))))

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.