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
addicted87
Helper I
Helper I

evaluation of sales selected employee vs. Compare Group

hi @all,

 

following problem:

 

I have 3 products: P1, P2, P3

I have 4 employees: E1, E2, E3, E4

 

now I have follwing table:

 

product, sales, employee

productsalesemployee
P110E1
P15E2
P115E3
P13E4
P220E2
P210E3
P330E2
P325E4

 

 

What I like to do is now:

 

I need a table showing following result, when I select employee E1

 

productsales selected employee E1sales other employees
P11023
P20 or blank30
P30 or blank

55

 

But if i select E1 in dimension employee, I filter the data, so I will get just the row for P1, but I like to see the other rows as well. How can I fix that?

 

thanks for your help.

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @addicted87 ,

Based on your descriton, you can extract the employee as a single table to use it as a slicer:

Employee = DISTINCT('Table'[employee])

Create these two measures:

Selected emplyee sales =
VAR _sum =
    CALCULATE (
        SUM ( 'Table'[sales] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[employee] IN DISTINCT ( 'Employee'[employee] )
                && 'Table'[product] IN DISTINCT ( 'Table'[product] )
        )
    )
RETURN
    IF ( ISBLANK ( _sum ), 0, _sum )
Other employees sales =
CALCULATE (
    SUM ( 'Table'[sales] ),
    FILTER ( ALL ( 'Table' ), 'Table'[product] IN DISTINCT ( 'Table'[product] ) )
) - [Selected emplyee sales]

employee.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @addicted87 ,

Based on your descriton, you can extract the employee as a single table to use it as a slicer:

Employee = DISTINCT('Table'[employee])

Create these two measures:

Selected emplyee sales =
VAR _sum =
    CALCULATE (
        SUM ( 'Table'[sales] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[employee] IN DISTINCT ( 'Employee'[employee] )
                && 'Table'[product] IN DISTINCT ( 'Table'[product] )
        )
    )
RETURN
    IF ( ISBLANK ( _sum ), 0, _sum )
Other employees sales =
CALCULATE (
    SUM ( 'Table'[sales] ),
    FILTER ( ALL ( 'Table' ), 'Table'[product] IN DISTINCT ( 'Table'[product] ) )
) - [Selected emplyee sales]

employee.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

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

amitchandak
Super User
Super User

@addicted87 , Try measures like

sales selected employee= sum(Table[sales])

sales other employees = calculate([sales selected employee], all(Table)) -[sales selected employee]

 

I needed , try first measure with +0

sales selected employee= sum(Table[sales])+0

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

thx for your reply @amitchandak ,

 

your measure works well for product p1, BUT I will still get just one row (for p1) in my result table, instead of 3 (p1, p2, p3). The problem ist, that there is no dataset für p2 or p3 for the employee p1, so if i filter dimension employee, I will product dimension as well. Thats the big problem. Is there a way, not get all vales of product in the table?

addicted87_0-1602241283446.png

In Qlik Sense it looks like this. I select via filter employee 1, and get the first measure (column 2). Then I sum up all sales for the other employees, excluded emplyee e1.

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.