cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dorinda
Super User
Super User

Filter from Button pressed on gallery and current user

I am trying to filter a gallery based on the current user logged in for a specific SharePoint list.

 

I have this code sorta working

SortByColumns(
    Filter(
        'POWER SYSTEM ELECTRICIAN Work Hours',

        'Apprentice Name' = Upper(varCurrentUserFullName), Month="July"
    ),
    "Date",
    Descending
)

I could have multiple entries for each month and year that need to be summed and filter, sort based on the button clicked on the previous gallery to filter the data

 

Dorinda_2-1657658132548.png

Both of the records are mine but I want them rolled up and summed per category.  I am stuck on how to add the filter from one gallery to another.

 

 My SharePoint list I have the Apprentice Name, Year, and Month

 

1 ACCEPTED SOLUTION

Accepted Solutions
Dorinda
Super User
Super User

Well it took me a few days but I have it working here is my solution

If(
    IsBlank(vFilter & wQtr & vYear),
    Filter(
        'POWER SYSTEM ELECTRICIAN Work Hours',
        ApprenticeName.Email = CurrentUserEmail
    ),
    If(
        !IsBlank(vFilter),
        Filter(
            'POWER SYSTEM ELECTRICIAN Work Hours',
            ApprenticeName.Email = CurrentUserEmail && (Month = vFilter)
        ),
        If(
            !IsBlank(wQtr),
            Filter(
                'POWER SYSTEM ELECTRICIAN Work Hours',
                ApprenticeName.Email = CurrentUserEmail && (Quarter = wQtr)
            )
        )
    )
)

View solution in original post

3 REPLIES 3
Dorinda
Super User
Super User

I am really struggling with this can someone please help me. @aprildunnam 

Dorinda
Super User
Super User

Ok so since no one is helping me here is what I have so far.

 

I got this code to sort of work I need to filter the gallery based on the user signed in to the app.

 

SortByColumns(
    If(
        IsBlank(vFilter),
            Filter(
        'POWER SYSTEM ELECTRICIAN Work Hours',
        'Apprentice Name' = Upper(varCurrentUserFullName)
    ),
        Filter(
            'POWER SYSTEM ELECTRICIAN Work Hours',
            Month = vFilter
        )

    ),
    "Date",
    Descending
)

 

However, it acts like it is doing it but it really isn't. As you can see from the image below I am logged in user, but it is displaying other user information.

Dorinda_0-1658153742458.png

 

I have this on the month filter buttons but it resets the filter of the gallery back to all users instead of just the current user logged in.

 

UpdateContext({vFilter:"MAY"})

 

I still haven't figured out how to make the Quarter buttons work yet.  I have this code that @WarrenBelz  provided, but I also need to be able to filter by the month as well.

 

With(
   {
      wQtr:
      Text(
         RoundUp(
            Month(Now()) / 3,
            0
         )
      )
   },
   SortByColumns(
      Filter(
         'POWER SYSTEM ELECTRICIAN Work Hours',
         StartsWith(
            'Apprentice Name',
            varCurrentUserFullName
         ) &&
         Quarter = wQtr
      ),
      "Date",
      Descending
   )
) 

 

  So in short I need to have the gallery filtered by the user who is logged in, then filter that same data by month and quarter and possibly by year!

 

I would really appreciate any help!

Dorinda
Super User
Super User

Well it took me a few days but I have it working here is my solution

If(
    IsBlank(vFilter & wQtr & vYear),
    Filter(
        'POWER SYSTEM ELECTRICIAN Work Hours',
        ApprenticeName.Email = CurrentUserEmail
    ),
    If(
        !IsBlank(vFilter),
        Filter(
            'POWER SYSTEM ELECTRICIAN Work Hours',
            ApprenticeName.Email = CurrentUserEmail && (Month = vFilter)
        ),
        If(
            !IsBlank(wQtr),
            Filter(
                'POWER SYSTEM ELECTRICIAN Work Hours',
                ApprenticeName.Email = CurrentUserEmail && (Quarter = wQtr)
            )
        )
    )
)

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 (2,902)