Forum Discussion
If Statement Working With Two Seperate Database Tables
Hello Everyone,
I have an request that has been causing me some trouble on how to resolve.
I have a need for a new column to be created which uses an If or Case statement where possible.
I need to link two tables together and then based on the result show it in a new column the value either Order or No Order.
In this example the Customer Table is a 1 to a Many on the Order Table with a cross filter direction of Single.
### SQL Statement ###
SELECT
<<< REMOVED FIELDS NOT NEEDED >>>
FROM SYSADM.CUSTOMER
WHERE NOT EXISTS (SELECT AH_IDENT FROM SYSADM.ORDER WHERE SYSADM.CUSTOMER.ID = SYSADM.ORDER.AH_IDENT
AND SYSADM.CUSTOMER.ID != '0'
AND NOT SYSADM.CUSTOMER.LOCKED = '1' OR SYSADM.CUSTOMER.LOCKED = '3'
### Attempted IF Statement ###
$Column Customer Ordered = IF(
'SYSADM ORDER'[AH_IDENT] = 'SYSADM CUSTOMER'[ID],
'SYSADM CUSTOMER'[ID] <> "0",
NOT 'SYSADM CUSTOMER'[LOCKED] IN "1","3"
,"Order","No Order"
)
When I use the following statement it advises that - Too many arguments were pased to the IF function. The maximum argument count for the function is 3.
Cheers, Everyone.
7 Replies
- rajulshahResident Rockstar
Maverick_BI
You can use the following DAX function:$Column Customer Ordered = IF( 'SYSADM ORDER'[AH_IDENT] = 'SYSADM CUSTOMER'[ID] && 'SYSADM CUSTOMER'[ID] <> "0" || NOT 'SYSADM CUSTOMER'[LOCKED] IN "1","3" ,"Order","No Order" )Let me know if this didn't help.
- Maverick_BINew Member
Hello rajulshah,
Thank you for the quick response unfortunately the same message appeared as what I am trying to resolve as shown below.
- rajulshahResident Rockstar
Maverick_BI Are you creating a new measure or new column?