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
RemiAnthonise
Helper V
Helper V

Multiple values in SELECTEDVALUE

Hi guys, 

I have this formula:

Workinghours per month
IF (
SELECTEDVALUE
('Workers'[Name])
= "Test Employee";
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays days] ) ) * [Workinghours9];
CALCULATE ( SUMX ('Calendar'; 'Calendar'[Workdays 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?

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community 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

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community 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

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @RemiAnthonise

 

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.

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.