cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Satyajit
New Member

Groupby Year for a date field in excel table

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

4 REPLIES 4
rebeccas
Community Champion
Community Champion

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.

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.

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

Thanks for the help. It really worked

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (3,671)