cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

How do you create a like button?

I would like to create a like button that counts number of likes. I tried using icons and buttons and have not been able to figure it out.
13 REPLIES 13
Highlighted
Anonymous
Not applicable

Re: How do you create a like button?

What is your setup? What are you trying to achieve? Do you have only 1 item that user can like or there could be many different items that users can like?

 

Creating a like button is fairly simple, depending on the rules you want to implement.

 

Scenario: Allow user to like multiple items once

If you want to allow your users to like each item only one time, you would have to do something like this:

 

Using SQL Server, have a table called

 

UserLikes with following columns

User (will keep track of which user clicked like by storing email address, or can be linked to User ID as foreign key if user table exists )

LikedRecord (will keep track of which record was liked by storing record ID, Foreign Key)

 

Column User + LikedRecord will be Primary Key.

 

now on each Item in a Gallery, add your like button and have the following functions

 

in LikeButton.OnSelect (this is the function to record to the datasource that like has been pressed by this user on this record)

Patch( '[dbo].[UserLikes]', Defaults('[dbo].[UserLikes]'), { User: User().Email,LikedRecord:ThisItem.RecordID } )

in LikeButton.DisplayMode (this is the function which checks if the user clicked like button before)

If(
  IsBlank(
    LookUp(
      '[dbo].[UserLikes]',
      User = UserID && LikedRecord = ThisItem.RecordID
    )
  ),
  DisplayMode.Edit,
  DisplayMode.Disabled
)

This is it, if you want to allow user liking one unique item in your App then you do not need to link it to recordID and just keep User email in the database and compare to it.

 

 

 

Highlighted
Anonymous
Not applicable

Re: How do you create a like button?

Thank you for your fast response!

 

Is it possible to create the like button using only excel and not SQL Server? My job is asking me to create an Idea submissions board using only sharepoint, excel, powerapps, and workflow.

Highlighted
Continued Contributor
Continued Contributor

Re: How do you create a like button?

Yup!

 

Just upload the excel document to DropBox. I used Dropbox + excel when I started learning.

 

Good luck!

Highlighted
Anonymous
Not applicable

Re: How do you create a like button?

@Anonymous

 

Yes you can use excel it will be the same setup but instead of database tables you will use excel tables.

Using excel will be sufficient, unless you go over 500 rows.

Highlighted
Helper I
Helper I

Re: How do you create a like button?

Hi, I want people to like/dislike outfits on my app, like tinder for outfits lets say 🙂 

 

I have  and dislike columns in my excel. 

 

When the user clicks the Like button under the image I want the column value to be increased by 1, same for dislike button. 

Also for each image if the user clicked Like button she/he shouldnt be able to click dislike button and viceversa. 

How can I do this? 

 

Thanks, 

Highlighted
Anonymous
Not applicable

Re: How do you create a like button?

Hi @pinarrehber

 

For this the very minimum requirement is one table like this:

 

Table:

Email, OutfitID, Value

 

Add a Like and Dislike button

 

LikeButton.OnSelect

Patch(
  '[dbo].[LikeDislikeTable]',
  Defaults('[dbo].[LikeDislikeTable]'),
  {
    Email:User().email,
    OutfitID:Gallery.Selected.OutfitID,
    Value:1
  }
)

Same code for dislike button (Change Value to -1)

 

Add a label that will show the count:

LikeCounter.Text

Sum(Filter('[dbo].[LikeDislikeTable]',OutfitID=Gallery.Selected.OutfitID),Value)

To allow votin gonly once, add this to the buttons.DisplayMode

LikeButton.DisplayMode

If(
  IsBlank(
Lookup(
'[dbo].[LikeDislikeTable]',
Email = User().Email && OutlookID = Gallery.Selected.OutlookID
)
),
DisplayMode.Edit,
DisplayMode.Disabled
)

Same formula for Dislike button.

 

Also I recomend using Global variable instead of User().Email since this function could lag.

Set(
  _UserEmail,
  User().Email
)
Highlighted
Helper I
Helper I

Re: How do you create a like button?

Hi, @Anonymous

 

Thank you so much for your reply 🙂 

 

One thing I couldnt get clear in my mind is that I want everyone in my organization to be able to use the app, so anyone can vote for the outfits, how do I have to set the email column? 

Highlighted
Helper I
Helper I

Re: How do you create a like button?

Hi, 

@Anonymous

 

Thank you so much for your reply 🙂 

 

One thing I couldnt get clear in my mind is that I want everyone in my organization to be able to use the app, so anyone can vote for the outfits, how do I have to set the email column? 

Highlighted
Anonymous
Not applicable

Re: How do you create a like button?

HI @pinarrehber

 

I am not sure if I understood your question. With the setup that I posed you can use it for your whole company. That table should be called something like UserOutfitTable and OutfitID should be a foreign Key to the main Outfit table that has all information about the Outfit plus Primary Key (OutfitID)

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,869)