web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Counting a total from ...
Power Apps
Answered

Counting a total from numbers in a Sharepoint list

(0) ShareShare
ReportReport
Posted on by 124

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!

 

Categories:
I have the same question (0)
  • Slaverty Profile Picture
    218 on at

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

     

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

  • Mira Ghaly Profile Picture
    11,415 Moderator on at

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

     

  • ZowieS Profile Picture
    124 on at

    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

     

     

  • ZowieS Profile Picture
    124 on at

    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?

     

     

  • Slaverty Profile Picture
    218 on at

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

  • ZowieS Profile Picture
    124 on at

    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 🙂

  • Verified answer
    Slaverty Profile Picture
    218 on at

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

     

  • ZowieS Profile Picture
    124 on at

    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

  • MH3 Profile Picture
    1,059 on at

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

     

     

  • Slaverty Profile Picture
    218 on at

    Hi @MH3 

     

    You probably want to start your own thread about this rather than tagging onto someone else's.

     

    But in case this solves your issue, taking a quick look I'd say you're missing a "First" formula.

    See, "EmployeLeaveBalance.'Annual Balance'" is a reference to a table, labels are unable to display tables.  What you need to do is provide the label with a value.  You can do this by wrapping your table reference with a "First" command.   Eg.

    First(EmployeeLeaveBalance).'Annual Leave'

     

    If that doesn't solve your issue, please start a new thread about this.

     

    Regards,
    Sean

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 474

#1
Valantis Profile Picture

Valantis 474

#3
WarrenBelz Profile Picture

WarrenBelz 375 Most Valuable Professional

Last 30 days Overall leaderboard