cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ZowieS
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

@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
Slaverty
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))

Mira_Ghaly
Dual Super User II
Dual Super User II

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

Blog: here

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

 

 

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?

 

 

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:

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 🙂

@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

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

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,073)