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
CC2019
Frequent Visitor

Select filtered AND unfiltered values in one column

Hello, Pundits!

 

I have one column with dates, one column with five distinct names (multiple rows of each name, though) and another column with the respective sales made for that particular name and date (again multiple rows). Basically, a day-by-day sales tracker made in Excel.

 

There are supposed to be just three salespersons on record, for billing purposes, though there is no limit on the number of people who can make sales over telephone.

 

What Im trying to do, is:

 

1. filter the sales for the three official salespersons into one column

2. filter the sales for the other two into another column

3. somehow distribute, evenly, the sales for the two unofficial salespersons, across the official three.

 

Ive been wrangling with sumx(filter combinations for a while now, and am reaching nowhere.

 

Searching across here and Google didnt really help, either, I understand the basics okay, i think, but maybe I'm dumber than I think I am.

 

Would appreciate any help anyone would be kind enough to send my way.

 

the closest I've come to getting anywhere is the below:

 

FilteredValues = IF(Sales[Sales]=0,0,SUMX(FILTER(Sales,OR(Sales[EmpId]=280,Sales[EmpId]=508)),Sales[Sales])
1 ACCEPTED SOLUTION
stevedep
Memorable Member
Memorable Member

Hi,

I have something for you which assumes this data model:

dmsales.jpg

So you have a list of offical reps and unoffical reps.

When you drag in the list of offical reps, the sales of the unoffical reps will be equally added:

repsales.jpg

This works by using the characteristic that some sales is blank, which is the sales of the unoffical reps. its broken down into pieces here.:

 

 

NoOfficialRepSales = CALCULATE(SUM(Sales[Sales Amount]);ISBLANK('Official Rep'[Rep])) 
NumberOfOfficalSalesReps = CALCULATE(COUNTX('Official Rep';SUM(Sales[Sales Amount])); ALLSELECTED('Official Rep'[Rep]))
AdditionalDistributedUnOfficialSales = DIVIDE([NoOfficialRepSales];[NumberOfOfficalSalesReps])
TotalSales =
IF (
    HASONEVALUE ( 'Official Rep'[Rep] );
    IF (
        NOT ( ISBLANK ( SELECTEDVALUE ( Sales[Rep] ) ) );
        SUM ( Sales[Sales Amount] ) + [AdditionalDistributedUnOfficialSales];
        BLANK ()
    );
    SUMX (
        ALLSELECTED ( 'Official Rep'[Rep] );
        CALCULATE ( SUM ( Sales[Sales Amount] ) )
    )
)

 

 

Link to file here.

Hope it works for you, if so, pls mark as solution. Thumbs up for the effort is appreciated.

Kind regards, Steve. 

p.s. 

 

NumberOfOfficalSalesReps should be labeled: NumberOfUNOffialSalesRepsales

 

View solution in original post

5 REPLIES 5
stevedep
Memorable Member
Memorable Member

Hi,

I have something for you which assumes this data model:

dmsales.jpg

So you have a list of offical reps and unoffical reps.

When you drag in the list of offical reps, the sales of the unoffical reps will be equally added:

repsales.jpg

This works by using the characteristic that some sales is blank, which is the sales of the unoffical reps. its broken down into pieces here.:

 

 

NoOfficialRepSales = CALCULATE(SUM(Sales[Sales Amount]);ISBLANK('Official Rep'[Rep])) 
NumberOfOfficalSalesReps = CALCULATE(COUNTX('Official Rep';SUM(Sales[Sales Amount])); ALLSELECTED('Official Rep'[Rep]))
AdditionalDistributedUnOfficialSales = DIVIDE([NoOfficialRepSales];[NumberOfOfficalSalesReps])
TotalSales =
IF (
    HASONEVALUE ( 'Official Rep'[Rep] );
    IF (
        NOT ( ISBLANK ( SELECTEDVALUE ( Sales[Rep] ) ) );
        SUM ( Sales[Sales Amount] ) + [AdditionalDistributedUnOfficialSales];
        BLANK ()
    );
    SUMX (
        ALLSELECTED ( 'Official Rep'[Rep] );
        CALCULATE ( SUM ( Sales[Sales Amount] ) )
    )
)

 

 

Link to file here.

Hope it works for you, if so, pls mark as solution. Thumbs up for the effort is appreciated.

Kind regards, Steve. 

p.s. 

 

NumberOfOfficalSalesReps should be labeled: NumberOfUNOffialSalesRepsales

 

Hi Steve,

 

That worked a CHARM! Exactly what I had in mind, while wrangling with the problem.

 

Had the separate tables, couldn't quite get them to play together.

 

Your post just makes everything so very clear and simple.

 

Thank you, Sir!

AllisonKennedy
Super User
Super User

You can use the || as an OR filter to get the three Sales people into the one FILTER expression (just replace the 209 with the ID you want):

IF(Sales[Sales]=0,0,SUMX(FILTER(Sales,Sales[EmpId]=280||Sales[EmpId]=508||Sales[EmpId]=209),Sales[Sales]))

Are you happy having the employee id hard coded into the measure?

Once you've got the part above working, you'll need to do something similar to add the remaining sales, but will probably need to use ALL or something else to clear filters on that part depending on what visual you want to use it in.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi Allison,

 

Thank you, that works. ALL helps with the remaining sales, too.

 

I did plug this in, and get the results I wanted, yet have decided to use Steve's solution as it is something new for me to learn and add to the knowledge base.

 

Wonderful community, this, always amazing people helping out. I'm in awe.

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.

Top Solution Authors