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
GellaiTamas
Helper I
Helper I

SEARCH + What-if + multiple tables

Hi,

 

Here is the situation:

I'd like to create a measure which is based on:

- what country the user chooses (dropdown)

- what vehicle type is chosen (dropdown)

- how many vehicles are we talking about (what-if slicer)

 

Uniform costs for the vehicle drivers are different in different countries but are the same no matter which vehicle type we choose - EXCEPT if we choose "Trailer" because the uniform cost in this case is 0.

 

So I'd like to multiply the uniform cost of the chosen country by the number of vehicles but calculate with 0 if "trailer" is chosen for the vehicle type.  

 

whatif_search.JPG

 

 

This is the code I use - which results in syntax error:

 

UniformTotalCost = 
VAR AnnualUniformCost =
	CALCULATE(
		SUM(
			'Uniform1'[Annual uniform cost]))
			
VAR UniformCost1 =
CALCULATE(
	SUM('Vehicle_costs'[Vehicle]),
		IF(
			ISERROR(
				SEARCH("Trailer",'Vehicle_costs'[Vehicle],,)),AnnualUniformCost * [# of vehicle Value],0
				)
			)

Could you please suggest how to tackle this?

 

Thanks,

Tamás

1 ACCEPTED SOLUTION

@GellaiTamas,

Create the following column in Vehicle_cost table.

CheckTrailer = IF(ISERROR(SEARCH("Trailer",Vehicle_costs[Vehicle])),0,1)

Then create the following measures in Vehicle_cost table.

Measure = MAX(Uniform1[Annual])
Uniform Cost = IF(MAX(Vehicle_costs[CheckTrailer])=1,0,[Measure]*[# of vehicle Value])

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10

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.