cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate II
Advocate II

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
Highlighted

@ZowieS 

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')

 

View solution in original post

10 REPLIES 10
Highlighted
Advocate III
Advocate III

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

 

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

Highlighted

@ZowieS 

 

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

 

ClearCollect(list1,AddColumns('Sharepoint List',"User",CC.DisplayName));

// 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

ClearCollect(list3,AddColumns(list2,"SUM",Sum(UserGroup,DAYS)));

//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 this post helps you with your problem, please mark your as Accepted solution.

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.
Highlighted

Hi @Slaverty,

 

Sorry, that didn't work. 

I got the following error message:

ZowieS_0-1596718252925.png

ZowieS_1-1596718293476.png

ZowieS_2-1596718316766.png

 

 

Highlighted

Hi @Mira_Ghaly,

 

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

 

"ClearCollect(list1,AddColumns('Sharepoint List',"User",CC.DisplayName));"

-What is "User"?

 

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

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

 

 

Highlighted

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)"

Highlighted

Hi @Slaverty,

 

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

ZowieS_0-1596785875437.png

 

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 🙂

Highlighted

@ZowieS 

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')

 

View solution in original post

Highlighted

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

Highlighted

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.

Annual.jpg

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

 

Any IDea??

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (5,266)