IF function is used incorrectly:the second input (if-result) and third input(else-result) should hav

Hello there.

In the last week, I have started with the development of an app to record computer inventory, including computers, cell phones and software licenses.

It could be said that there are two types of licenses, one "Assigned" to a device, and another "Inherited", if that same "Assigned" license is used occasionally with another device. Naturally this data type is an Enum. This information is found in the Software table and in the [License type] column.

When selecting the license type, if it is "Assigned" a Text type field is displayed to enter the license code by hand, Software[License SN]. On the other hand, if it is "Inherited" a drop-down is displayed (Software[Shared Device]) and I select the device with which it is sharing license Software[Device ID].

The problem comes with the costs, if it is "Assigned" I want to enter the data manually but if it is "Inherited" I would like to automatically charge the same cost that has the license for the original device in which it was assigned.

So I have thought of using the following expression in the corresponding Initial Value:
IF(
[License Type]="Assigned",
0,
SELECT(Software[Cost],[Device ID] = [_THISROW].[Shared Device])
)

But I get the following error message IF function is used incorrectly:the second input (if-result) and third input(else-result) should have the same type.

The data type of the Cost column is Price.

Do you know what could be the cause of this error?

 

Solved Solved
0 2 575
1 ACCEPTED SOLUTION

SELECT returns a list. To get a single value try INDEX(SELECT(...),1).

View solution in original post

2 REPLIES 2

SELECT returns a list. To get a single value try INDEX(SELECT(...),1).

Hi, finally i have to use my SELECT expression with another SELECT function to get the target row but also i have to use your solution. 

 

Also keep in mind for this particular case that if you share a license, the "Software name" field will be common between both devices (Microsoft Office, Photoshop, Adobe Illustrator...) and as I also had this value stored, I used it to filter the corresponding row.

Thus, the expression is.

INDEX(
SELECT(
Software[Cost], [id_software]=
(INDEX(FILTER("Software", AND((([Device ID] = [_THISROW].[Shared Device]), ([Software name] = [_THISROW].[Software name])))),1))
)
),1)

 

 

Top Labels in this Space