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

Splitting Matrix Columns Based on Selection

Hello, I would like my matrix columns to be split based on if Employee is selected ("Yes") or not selected ("No").

 

I have my Base Table

ProductEmployeeUnits
AppleA1
PearA2
AppleB3
PearB4
AppleC5
PearC6
 
 

and Selection Table

Employee
A
B
C

 

Here is an example of the desired outcome if I select "A" from the selection table

ProductIn SelectionOut of Selection
Apple18
Pear210

 

I am new to Power BI and DAX, my experience in mostly in Tableau. If there is a solution that doesn't require the Selection Table, that is good too.

 

Thanks!

1 ACCEPTED SOLUTION
littlemojopuppy
Community Champion
Community Champion

Hi!  You're going to want to create two different measures that use the SELECTEDVALUE function, one for the total for employee selected and the other for all employees except the selected one.

 

Probably not syntactically perfect, but this should be close...

VAR
	SelectedEmployee = SELECTEDVALUE(Employee[Employee])
RETURN

CALCULATE(
	SUM(BaseTable[Units])
	Employee[Employee] = SelectedEmployee
)



VAR
	SelectedEmployee = SELECTEDVALUE(Employee[Employee])
RETURN

CALCULATE(
	SUM(BaseTable[Units])
	Employee[Employee] <> SelectedEmployee
)




View solution in original post

2 REPLIES 2
littlemojopuppy
Community Champion
Community Champion

Hi!  You're going to want to create two different measures that use the SELECTEDVALUE function, one for the total for employee selected and the other for all employees except the selected one.

 

Probably not syntactically perfect, but this should be close...

VAR
	SelectedEmployee = SELECTEDVALUE(Employee[Employee])
RETURN

CALCULATE(
	SUM(BaseTable[Units])
	Employee[Employee] = SelectedEmployee
)



VAR
	SelectedEmployee = SELECTEDVALUE(Employee[Employee])
RETURN

CALCULATE(
	SUM(BaseTable[Units])
	Employee[Employee] <> SelectedEmployee
)




Anonymous
Not applicable

Thank you. This solution works. I don't like that Power BI doesn't have a dynamic "set/group" solution because that would only be one variable, rather than one for each measure. But since it looks like they don't have this option, this is a good solution. Thanks!

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.