Reputation: 572
so i want to put calculate field, if the contains selected product, then it appear number of count order (id for transaction) of that product (on this case, using count distinct for order_match_id (its the id for every transaction)
im using this
IF CONTAINS([Selected Product], [Name])
THEN (CNTD([Order Match Id])
ELSE NULL
END
but its says Expected Closing paranthesis for the expression starting at characted 47
the point is, i want to make some else if condition, if the condition true, then appearing count distinct of id transaction to provide how many transaction
Upvotes: 1
Views: 600
Reputation: 572
after posting this question on tableau community, this is the best answer so far
they are probably not the right dimensions but see the use of atta and countd
IF CONTAINS(attr([Kategori]), attr([Name]))
THEN COUNTD([Order Match Id])
ELSE NULL
END
Upvotes: 0
Reputation: 3167
Even though you may want to add more logic to your statement, you should remember that you cannot mix aggregated with non aggregated values.
Basically, your formula should be more like this:
COUNTD(IF CONTAINS([Selected Product], [Name])
THEN [Order ID]
ELSE NULL
END)
Doing so, "first" you test your condition for each row and "then" you aggregate values using COUNTD (not cntd)
Upvotes: 2