cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nicolas_1999
Helper I
Helper I

Grouped Graph

Good afternoon,

 

I have a question about making a Graph.

I wanna show the total of items created per country for each week.

When I add a new Column it won't group the Countries but show them seperate.

I have been at this for a few hours now but can not figure it out.

This is the AddColumns I use:

 

AddColumns('NAME OF SHAREPOINT'; "ShowCountry"; ThisRecord.'Country/Department'.Value; "ShowDivision"; ThisRecord.Division.Value)

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Nicolas_1999 

Sorry, looks like a typo in my formula for the filter.

Should be:

AddColumns(
    GroupBy(
        AddColumns(
            Filter('Weekly Status DEV POWERAPP'; 'Date opened' >= DateAdd(Today(); -7; Days));
            "ShowCountry"; ThisRecord.'Country/Department'.Value;
            "ShowDivision"; ThisRecord.Division.Value
        );
        "ShowCountry"; "_data"
    );
    "_count"; CountRows(_data)
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

7 REPLIES 7
RandyHayes
Super User
Super User

@Nicolas_1999 

You need to utilize the GroupBy function for this.

Please consider changing your Formula to the following:

AddColumns(
    GroupBy(
        AddColumns('NAME OF SHAREPOINT'; 
            "ShowCountry"; ThisRecord.'Country/Department'.Value;
            "ShowDivision"; ThisRecord.Division.Value
        );
        "ShowCountry"; "_data"
    );
    "_count"; CountRows(_data)
)

Your primary graphed columns would then be ShowCountry and _count.

I am not sure what you are using ShowDivision for, but I left it in the formula.

 

Also, the only reason the inner AddColumns was needed is because you appear to have choice columns for country and division, so they needed to be pulled out to another column name and then grouped.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes,

 

First of all thanks alot it fully worked!

 

Second question if it isn't to much to ask.

Would you know how I could make this data show for each week?

Right now it will show all the data in total.

RandyHayes
Super User
Super User

@Nicolas_1999 

Well, I am not sure what your criteria or columns are for determining a week.  Or if you want to show a set week (Sun to Sat) or a Week range (today and the past 7 days).

 

However, all you want then would be done with a Filter in the formula.

i.e.

AddColumns(
    GroupBy(
        AddColumns(
            Filter('NAME OF SHAREPOINT'; criteriaToResultInAWeek);
            "ShowCountry"; ThisRecord.'Country/Department'.Value;
            "ShowDivision"; ThisRecord.Division.Value
        );
        "ShowCountry"; "_data"
    );
    "_count"; CountRows(_data)
)

Replace the criteriaToResultInAWeek with the criteria you would use to return one week of data.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

For example I have a date field in my sharepoint list called Opened Date.

Would it be something like this?

 

AddColumns(
    GroupBy(
        AddColumns(
            Filter('Weekly Status DEV POWERAPP'; 'Date opened' <= 7 ;
            "ShowCountry"; ThisRecord.'Country/Department'.Value;
            "ShowDivision"; ThisRecord.Division.Value
        );
        "ShowCountry"; "_data"
    );
    "_count"; CountRows(_data)
)
RandyHayes
Super User
Super User

@Nicolas_1999 

No, more like this:

AddColumns(
    GroupBy(
        AddColumns(
            Filter('Weekly Status DEV POWERAPP'; 'Date opened' >= DateAdd(Today(); -7; Days);
            "ShowCountry"; ThisRecord.'Country/Department'.Value;
            "ShowDivision"; ThisRecord.Division.Value
        );
        "ShowCountry"; "_data"
    );
    "_count"; CountRows(_data)
)

That would include all records dated 7 days ago or newer.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

Sorry im not the best at power apps 😞

That doesn't seem to be working either, I tried to fix it but no idea what is going wrong.

Nicolas_1999_0-1638809962540.png

 

 

@Nicolas_1999 

Sorry, looks like a typo in my formula for the filter.

Should be:

AddColumns(
    GroupBy(
        AddColumns(
            Filter('Weekly Status DEV POWERAPP'; 'Date opened' >= DateAdd(Today(); -7; Days));
            "ShowCountry"; ThisRecord.'Country/Department'.Value;
            "ShowDivision"; ThisRecord.Division.Value
        );
        "ShowCountry"; "_data"
    );
    "_count"; CountRows(_data)
)
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (6,143)