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.
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?
Solved! Go to Solution.
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
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
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.
@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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |