A formula that give an option of what text display in row

I have a product table and on product detail page I want to display โ€˜likeโ€™ or โ€˜unlikeโ€™ depending on whether the user already like the product. I have set up a likes table that contains column Like and Email. Then tried using this formula but its not working as I want it to

IF(and([Likes].[Like]<>0,[Likes].[Email]=useremail())=false, โ€œLikeโ€, โ€œUnlikeโ€)

Any ideas or suggestion on how to go about it?

Solved Solved
1 5 255
1 ACCEPTED SOLUTION

I ended up with the following formula which is working perfectly. Thanks all

IF(in(useremail(),SELECT(Likes[Email], ([Product Id] = [Likes].[Product Id])))=true, โ€œUnlikeโ€, โ€œLikeโ€)

View solution in original post

5 REPLIES 5

What if you remove the portion =false ?

that wasnโ€™t working either. thanks

Good to know that you have it working, please mark the working formula as per your post as acceptable answer.

I ended up with the following formula which is working perfectly. Thanks all

IF(in(useremail(),SELECT(Likes[Email], ([Product Id] = [Likes].[Product Id])))=true, โ€œUnlikeโ€, โ€œLikeโ€)

That expression is still a bit confusing to me. I presume you have a table called Likes with two columns โ€“ Product and Email.

How about something like this:

IF ( COUNT( SELECT(Likes[Email], AND([ProductId] = [_THISROW].[ProductId], [Email] = USEREMAIL()))) > 0, โ€œUnlikeโ€, โ€œLikeโ€)

Perhaps you already have a virtual column Likes on the Products table which is a list of refs to all Likes for the productโ€ฆ If so โ€ฆ

IF ( IN(USEREMAIL(), [Likes][Email]), โ€œUnlikeโ€, โ€œLikeโ€)

Top Labels in this Space