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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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