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

How to caculate a measure for the visual based on the inverse slicer selection

Hi everyone,

 

I am looking for help on how to calculate the measure that would summarize the table results based on the inverse user's slicer selection.

 

The measure is one of many within the report (the others are based directly on the slicer selections).

 

Below is an example. My objective is to have the yellow cell contain a result of the calculation for all the company codes different to CH10.

 

Example.JPG

 

I'd be really grateful for help.

 

Regards

Krzysztof

1 ACCEPTED SOLUTION

@Anonymous my bad it should be

 

measures = 
VAR __CompanyCode =   VALUES ( Table[CompanyCode] ) 
VAR __selectedCompanyCode = SELECTEDVALUE ( Table[CompanyCode] )
RETURN
CALCULATE( 
SUM ( Table[Active] ), 
ALL ( Table[CompanyCode] ) , 
IF ( __selectedCompanyCode == BLANK(), 1 , NOT Table[CompanyCode] IN __CompanyCode ) 
)

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

9 REPLIES 9
v-deddai1-msft
Community Support
Community Support

Hi @Anonymous ,

 

Would you please first create a calculated table for you company code slicer ?

 

_slicer = values('Table'[Company Code])

 

Then use the following measure to get the calculation for all the company codes different to the selected values from slicer.

 

Measure =

VAR  slicer = VALUES('Slicer'[Company Code])

RETURN

CALCCULATE(SUM('Table'[Values]),FILTER(ALL('Table'), NOT('Table'[Company Code] in _slicer)))

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

@v-deddai1-msft thanks for your comments. 

 

I tried out your proposed solution but unfortunately get blank as a result of the calculation.

 

I defined the table as you instructed, including the accurate names it looks like this:

_slicer = VALUES('AO source'[Company Code])
 
Then defined the measure: 
 
MeasureTEST = VAR slicer = VALUES(_slicer[Company Code])
RETURN
CALCULATE(SUM('AO source'[Management base period]),FILTER(ALL('AO source'), NOT('AO source'[Company Code] in _slicer)))
 
But when displaying the measure value in any visual (table, card etc. ) I get blank as a result. 
 
What am I doing wrong ? 

 

Regards

Krzysztof 

@Anonymous did you tried the solution I proposed, you never clarified that if it worked or not.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@Anonymous try following measure, change column and table name as per your model

 

measures = 
VAR __CompanyCode =   VALUES ( Table[CompanyCode] ) 
VAR __selectedCompanyCode = SELECTEDVALUE ( Table[CompanyCode] )
RETURN
CALCULATE( 
SUM ( Table[Active] ), 
ALL ( Table[CompanyCode] ) , 
IF ( __selectedCompanyCode == BLANK(), 1 , NOT Table[CompanyCode] IN __room ) 
)

 

I would 💖Kudos 🙂 if my solution helped. If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k thank you for help.

 

I tired it out a moment ago and have a question. What does the '__room' component in the below line refer to ? I assume it must be some calculated table but I haven't defined it. I guess it's a table that dynamically captures slicer's selections. Would you know how to create it ?   

 

IF ( __selectedCompanyCode == BLANK(), 1 , NOT Table[CompanyCode] IN __room ) 

 

Regards

Krzysztof

Anonymous
Not applicable

To illustrate it a bit better the measure which I updated with my names looks in a following way:

 

measures =
VAR __CompanyCode = VALUES ( 'AO source'[Company Code])
VAR __selectedCompanyCode = SELECTEDVALUE ( 'AO source'[Company Code] )
RETURN
CALCULATE(
SUM ( 'AO source'[Management base period] ),
ALL ( 'AO source'[Company Code] ) ,
IF ( __selectedCompanyCode == BLANK(), 1 , NOT 'AO source'[Company Code] IN __room )
)
 
K.

@Anonymous my bad it should be

 

measures = 
VAR __CompanyCode =   VALUES ( Table[CompanyCode] ) 
VAR __selectedCompanyCode = SELECTEDVALUE ( Table[CompanyCode] )
RETURN
CALCULATE( 
SUM ( Table[Active] ), 
ALL ( Table[CompanyCode] ) , 
IF ( __selectedCompanyCode == BLANK(), 1 , NOT Table[CompanyCode] IN __CompanyCode ) 
)

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

@parry2k THANK YOU !!! 🙂

@Anonymous glad it worked out.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.