Forum Discussion
Multiple values in SELECTEDVALUE
Hi guys,
I have this formula:
Workinghours per month=
IF (
SELECTEDVALUE
('Workers'[Name])
= "Test Employee";
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays 4 days] ) ) * [Workinghours9];
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays 5 days] ) ) * [Workinghours8]
)
This works fine.
I want to give it multiple values, let's say:
Workinghours per month=
IF (
SELECTEDVALUE
('Workers'[Name])
= "Test Employee" || "Test Person";
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays 4 days] ) ) * [Workinghours9];
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays 5 days] ) ) * [Workinghours8]
)
I get the following error:
"Calculationerror in measure Workinghours per month: cannot convert value Test Person of the type Text tot the type True/False."
How can I do this?
Hi RemiAnthonise,
Here we can use IF and OR instead of ||
Workinghours per month both = IF ( OR( SELECTEDVALUE('Workers'[Name])= "Test Employee"; SELECTEDVALUE('Workers'[Name])= "Test Person"); CALCULATE(SUMX('Calendar';'Calendar'[Workdays 4 days]))* [Workinghours9], CALCULATE(SUMX('Calendar';'Calendar'[Workdays 5 days]))* [Workinghours8])There is an example in the attached pbix.
https://www.dropbox.com/s/eudlobbyoz279bz/Multiple%20values%20in%20SELECTEDVALUE.pbix?dl=0
Regards,
Frank
3 Replies
- v-frfei-msftCommunity Support
Hi RemiAnthonise,
Here we can use IF and OR instead of ||
Workinghours per month both = IF ( OR( SELECTEDVALUE('Workers'[Name])= "Test Employee"; SELECTEDVALUE('Workers'[Name])= "Test Person"); CALCULATE(SUMX('Calendar';'Calendar'[Workdays 4 days]))* [Workinghours9], CALCULATE(SUMX('Calendar';'Calendar'[Workdays 5 days]))* [Workinghours8])There is an example in the attached pbix.
https://www.dropbox.com/s/eudlobbyoz279bz/Multiple%20values%20in%20SELECTEDVALUE.pbix?dl=0
Regards,
Frank- kohlivinayakResolver I
Create a new measure for selected value
Selected = SELECTEDVALUE
('Workers'[Name])IF ( Selected = "Test Employee" || Selected = "Test Person";
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays 4 days] ) ) * [Workinghours9];
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays 5 days] ) ) * [Workinghours8]
)the thing is you have to repeat the expression it has to compare.
A better approach is what v-frfei-msft has already told you.
- RemiAnthoniseHelper V
kohlivinayak yes you're right, I've tried the way as v-frfei-msft told me and this did the trick.
Thanks for your time, guys.