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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jameli
Frequent Visitor

Dax help needed with outlier case for all selected groups (ALLSELECTED)

I have a case where I would have to calculate a % of total of sales for 2 selected groups but only one of them is in visual.

Here's my data in picture

So I would like to first select Groups B and C, then select products only from C (Green and Yellow grapes). Then I would like to see the percentage of sales Green and Yellow Grapes contributed to Total sales of Groups B and C.

So Desired outcome would be for Green grapes (30 / 70) ~43% and for Yellow Grapes (10/70) ~14%.

I tried using ALLSELECTED but it does not work when I only have Group C products selected in visual. 

This video got me pretty close, but it's not working since there are only Group C products in visual: 

DAX Fridays! #118:  Get selected or multiple values from slicers using DAX


Any ideas is this even possible or how to proceed?

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your dataset looks like, but one of ways to create a solution is to have dimension table for Group, like below. In this case, Group slicer won't be influenced by the product selection.

 

Picture2.png

 

Percent of sales from selected groups: = 
VAR _sales = [Sales measure:]
VAR _selectedgroup =
    VALUES ( 'Group'[Group] )
VAR _grouptotal =
    CALCULATE (
        [Sales measure:],
        FILTER ( ALL ( Data ), Data[Group] IN _selectedgroup )
    )
RETURN
    DIVIDE ( _sales, _grouptotal )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your dataset looks like, but one of ways to create a solution is to have dimension table for Group, like below. In this case, Group slicer won't be influenced by the product selection.

 

Picture2.png

 

Percent of sales from selected groups: = 
VAR _sales = [Sales measure:]
VAR _selectedgroup =
    VALUES ( 'Group'[Group] )
VAR _grouptotal =
    CALCULATE (
        [Sales measure:],
        FILTER ( ALL ( Data ), Data[Group] IN _selectedgroup )
    )
RETURN
    DIVIDE ( _sales, _grouptotal )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks, this is how I would like it to work.

This unfortunately doesn't work straight away in my case since the dimension table is not joined by Group -field but another field. I could solve this by creating a another separate dimension which is joined by the Group field, but I'll have to think if I want to create a separate solution for this.

Maybe creating an inactive relation by group and using it in your solution with USERRELATIONSHIP would work as well.

johnt75
Super User
Super User

Try

% sales of selected group =
VAR currentSales = [Sales]
VAR selectedGroupSales =
    CALCULATE ( [Sales], ALLEXCEPT ( 'Product', 'Product'[Group] ) )
RETURN
    DIVIDE ( currentSales, selectedGroupSales )

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.