Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I created a slicer like this on PowerBI, but I would like the values to add up as "AND" conditions, rather than as "OR". For instance, I would like the values returned to be those where Chris Gray AND Carlos Grillo are managers, rather than Chris Gray OR Carlos Grillo are managers. How can I do this?
Solved! Go to Solution.
still not sure but try :
Selected Measure Value =
SWITCH(SELECTEDVALUE('Measures for Slicer'[Measure])
, "Managers", [Manager Names]
, BLANK()
)
Selected Measure Value (only for managers) =
// Get the number of managers you selected
VAR SelectedmanagerCount = CALCULATE(COUNTROWS(VALUES(table[managers]))
, ALLSELECTED(table))
VAR output = SUMX (
VALUES( table[manager] ), //Get each manager in the current context
VAR x = ADDCOLUMNS ( //For each manager, set a flag for whether
//there is data for each selected manager
ALLSELECTED ( table ),
"Flag", IF ( NOT (ISBLANK ( [Selected Measure Value] ), 1, 0 )
)
//Count up the number of sales with data for each manager
VAR salesWithDataFormanager = SUMX ( x, [Flag] )
//If the number of managers for the facility matches the number of
//selected managers, include that value, otherwise exclude it.
RETURN
IF ( salesWithDataFormanager = SelectedmanagerCount, [Selected Measure Value] )
)
RETURN output
Hi, you can have multiple selection by pressing CTRL and selecting other values
Hello! Thanks for the suggestion, but doing that only returns the *value "OR" value* results, which is what I am trying to avoid.
still not sure but try :
Selected Measure Value =
SWITCH(SELECTEDVALUE('Measures for Slicer'[Measure])
, "Managers", [Manager Names]
, BLANK()
)
Selected Measure Value (only for managers) =
// Get the number of managers you selected
VAR SelectedmanagerCount = CALCULATE(COUNTROWS(VALUES(table[managers]))
, ALLSELECTED(table))
VAR output = SUMX (
VALUES( table[manager] ), //Get each manager in the current context
VAR x = ADDCOLUMNS ( //For each manager, set a flag for whether
//there is data for each selected manager
ALLSELECTED ( table ),
"Flag", IF ( NOT (ISBLANK ( [Selected Measure Value] ), 1, 0 )
)
//Count up the number of sales with data for each manager
VAR salesWithDataFormanager = SUMX ( x, [Flag] )
//If the number of managers for the facility matches the number of
//selected managers, include that value, otherwise exclude it.
RETURN
IF ( salesWithDataFormanager = SelectedmanagerCount, [Selected Measure Value] )
)
RETURN output
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
15 | |
14 | |
11 | |
10 |