cancel
Showing results for
Did you mean:

Counting a total from numbers in a Sharepoint list

Hi,

I have a Sharepoint list where a column (text) has a numeric value (e.g 2) in it.

How do I show the totalt number for the current user?

The Data:

User A - 1 day

User A - 2 days

User B - 1 day

Result:

User A = 3 days

User B = 1 day

Background

I'm building a Leave-app and I want to show (to the current user) the total number of Leave days he/she has got approved on the current year.

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

Looking at your screenshot, it doesn't look like your days column is in the format "X Days" so try the following formula instead

``Sum(ForAll(Filter(LedighetV2, UPN = varUser.UserProfile.userPrincipalName), Value('Antal dagar')), Value)``

Essentially just removing the whole "Left" formula.

And if your days column is already formatted as a number, you should be able to further simplify to the below.

Sum(Filter(LedighetV2, UPN = varUser.UserProfile.userPrincipalName), 'Antal dagar')

10 REPLIES 10

So if you're storing usernames, you could try something like the following.

Count(Value(Filter(MyData, user = User().FullName).DaysColumn))

Multi Super User

Please try the below to genarate your collection that displays user , sum of days:

You add this formula on the visible of your screen or on the start property of your application

// Where CC  the your User Column name

ClearCollect(list2,GroupBy(list1,"User","UserGroup"));

User Group is your grouping name you can use as it is

//SUM is the new sum column that will be displayed on list3

//DAYS is the Days Column in your list

list3 can be used now as your table datasource.

If you like my response, please give it a Thumbs Up.

MG (Naturally Curious)

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here

Hi @Slaverty,

Sorry, that didn't work.

I got the following error message:

Hi @Mira_Ghaly,

I'm sorry but I don't fully understand.

-What is "User"?

"ClearCollect(list2,GroupBy(list1,"User","UserGroup"));"

-What should "UserGroup" be? Is it something from my Sharepoint List?

Apologies, I had hoped "Value" would have ignored the "Days" section of your column but I see from my own testing this is not the case.

Also, I shouldn't have used "Count", "Sum" would be required instead.

I have tested the below and it is working with the following assumptions - The usernames stored in your table match exactly the usernames of the logged in user, and secondly, your days column is all in the format "X Days" (*Number* space "Days")

``Sum(ForAll(Filter(YourData, Username = varCurUser), Value(Left(DaysColumn, Find(" ", DaysColumn)))), Value)``

I think you already know this based on your last reply, but to get the "varCurUser" I used "Set(varCurUser, User().FullName)"

Hi @Slaverty,

Thank you! It looks better. That works but I got nothing in return:

I should get " 1 " now. At least until I filter only on the "Approved"

@Slaverty wrote:

I think you already know this based on your last reply, but to get the "varCurUser" I used "Set(varCurUser, User().FullName)"

Yes, my varUser is my variable that contains information on the current logged in user such as UPN, Displayname, Manager, Direct reports etc etc 🙂

Hi,

Looking at your screenshot, it doesn't look like your days column is in the format "X Days" so try the following formula instead

``Sum(ForAll(Filter(LedighetV2, UPN = varUser.UserProfile.userPrincipalName), Value('Antal dagar')), Value)``

Essentially just removing the whole "Left" formula.

And if your days column is already formatted as a number, you should be able to further simplify to the below.

Sum(Filter(LedighetV2, UPN = varUser.UserProfile.userPrincipalName), 'Antal dagar')

Hi @Slaverty,

Ah, yes. The column only contains a number and the column is in text format (for now).

Both worked, Thank you so much for your help!

Cheers

Post Prodigy

Hi @Slaverty ,

I have two lists,

1) LeaveReQuets (List A)
2) EmployeeLeaveBalance (List B)

both list contains a Same column (Which is Person or Group) EmployeeName,

Now, I want to show the Number Column Value from List B in the label in PowerApps, by comparing the two person fields.

While Annual Balance is the Number Coloumn, I want to show the number in the Label.

Any IDea??

Announcements

Announcing Power Apps Copilot Cookbook Gallery

We are excited to share that the all-new Copilot Cookbook Gallery for Power Apps is now available in the Power Apps Community, full of tips and tricks on how to best use Microsoft Copilot as you develop and create in Power Apps. The new Copilot Cookbook is your go-to resource when you need inspiration--or when you're stuck--and aren't sure how to best partner with Copilot while creating apps.   Whether you're looking for the best prompts or just want to know about responsible AI use, visit Copilot Cookbook for regular updates you can rely on--while also serving up some of your greatest tips and tricks for the Community. Check Out the new Copilot Cookbook for Power Apps today: Copilot Cookbook - Power Platform Community.  We can't wait to see what you "cook" up!