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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Groupby Year for a dat...
Power Apps
Answered

Groupby Year for a date field in excel table

(0) ShareShare
ReportReport
Posted on by 6

Hi, I am new PowerApps. I need your help. I want to build a chart to show number of associates joined on each year. In excel table, I have date of join field. I am using following query, but it is not giving me desire result (in fact showing some error - The GroupBy is having invalid argument. Expecting number, but having text value). Can you please help me by pointing out where I am doing wrong?

AddColumns(
    GroupBy(
        hctable,
        Year(DateValue(Date_of_Join_Org)),
        "joindate"
    ),
    "Countofassociates",
    CountRows(joindate)
)

Here, hctable is the table name, Date_of_Join_Org is the field having various dates in mm/dd/yyyy format.

Categories:
I have the same question (0)
  • rebeccas Profile Picture
    2,591 on at

    Try this: 

     

    For your Gallery Items:

     

    GroupBy(AddColumns(hctable, "Year", Year(Date_of_Join_Org)),"Year","GrpByYear")

     

    Then in your gallery you can have a label that is : ThisItem.Year (if you want)

    From there you can refer it it...example:

    Label = CountIf(hctable, Year(Date_of_Join_Org)=ThisItem.Year)

     

    I use sharepoint so it does not need the DateValue() part, not sure if you do for excel.

  • Satyajit Profile Picture
    6 on at
    Thank you Rebecca. I could implement this using the gallery. However, not able to bring that as Pie Chart (or any other chart form). Further help will be appreciated.
  • Verified answer
    rebeccas Profile Picture
    2,591 on at

    When I want the data to show in a chart I put it in a collection and then set that collection for the items of the chart. 

     

    Screens OnVisible:

     

    ClearCollect(CollYearCount,

    AddColumns(GroupBy(AddColumns(hctable, "Year", Year(Date_of_Join_Org)),"Year","GrpByYear")

    ,"CountYear",CountRows(GrpByYear)))

     

    So you put that on the screens OnVisible (then click to another screen and back so it is created) and then you can put in your chart and set the Items of it to CollYearCount

  • Satyajit Profile Picture
    6 on at

    Thanks for the help. It really worked

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard