cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KimberlyM
Level 8

Sorting My Dashboard and Displaying Only 2 Status Types of 4

 

So I am trying to only display, on the load screen and onSelect of button of Active Leads 2 of 4 of my status types but I need it to load all 4 as the 2 I don't want displayed initially are pulled up through a tab button. 

I have this so far which displays all of my status types, Not Started, In Progress, Dead Deal and Completed Deal

Sort(
    Filter(
        If(
            !IsEmpty(
                Filter(
                    Administrators,
                    FullName = varUser
                )
            ),
            Lead_Data,
            Filter(
                Lead_Data,
                AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser
            )
        ),
        If(
            SelectedStatus = "All",
            true,
            Status.Value in SelectedStatus
        )
    ),
    "Created",
    If(
        SortByDate,
        Ascending,
        Descending
    )
)

I have tried to set my Show all Active button to Set(SelectedStatus, ["Not Started","In Progress"]).

I am so lost as I have been going in circles on this that I am not even sure I have all the important information here. I am hoping someone can help me! Thanks in advance!

 

5 REPLIES 5
Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: Sorting My Dashboard and Displaying Only 2 Status Types of 4

If I understand correctly, you want to filter down status types under different conditions. It appears you have two layers of filtering.

 

Filter 1: Filter leads by admin vs. not admin

  • If someone is an administrator, show everything
  • If someone is not an admin, pare down content to what has been assigned to them or they are a lead member.

 

Filter 2: show all or some statuses.

  • You want to use a variable SelectedStatus to determine what status is picked.

 

Filter 1 looks okay. To get Filter 2 correct, it's a matter of data types. 

Your current formula sets SelectedStatus as a table.

Set(SelectedStatus, ["Not Started","In Progress"])

But your condition attempts to match that table against text ("All").

 

        If(
            SelectedStatus = "All",
            true,
            Status.Value in SelectedStatus
        )

 

There's a few different ways of getting both sides of the condition to be the same. Here's one way:

  • Change the condition to find text within a table:
    "All" in SelectedStatus.Value
    Note that SelectedStatus in the way you have declared it using square brackets [] generates a one column table called "Value". So this condition searches for the text "All" in the Value column of the SelectedStatus table. 

 

 

PS: When using Sort() you do not use "" around the names of columns; only SortByColumns needs quotation marks.

 

 


@KimberlyM wrote:

 

So I am trying to only display, on the load screen and onSelect of button of Active Leads 2 of 4 of my status types but I need it to load all 4 as the 2 I don't want displayed initially are pulled up through a tab button. 

I have this so far which displays all of my status types, Not Started, In Progress, Dead Deal and Completed Deal

Sort(
    Filter(
        If(
            !IsEmpty(
                Filter(
                    Administrators,
                    FullName = varUser
                )
            ),
            Lead_Data,
            Filter(
                Lead_Data,
                AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser
            )
        ),
        If(
            SelectedStatus = "All",
            true,
            Status.Value in SelectedStatus
        )
    ),
    "Created",
    If(
        SortByDate,
        Ascending,
        Descending
    )
)

 

 


 

KimberlyM
Level 8

Re: Sorting My Dashboard and Displaying Only 2 Status Types of 4

@Mr-Dang-MSFT  thank you for your response. 

So I am setting my variables on loading the app as the below so that I can push my tab buttons to change the gallery view to just one of these items:

 

Set(SelectedStatus, "Not Started");
Set(SelectedStatus, "In Progress");
Set(SelectedStatus, "Dead Deal");
Set(SelectedStatus, "Completed Deal");


Then when I show the dashboard page (onVisible) I have this as shown below so that it will load the screen as I desire (however it is not loading as I desire right now):

// Collect data for the pie chart on dashboard screen 
    If(!IsEmpty(Filter(Administrators,FullName=varUser)),
        ClearCollect(colDash_StatusTrack,{Status:"Not Started",Count:CountIf(Lead_Data,Status.Value="Not Started")});
        Collect(colDash_StatusTrack,{Status:"In Progress",Count:CountIf(Lead_Data,Status.Value="In Progress")});
        //Collect(colDash_StatusTrack,{Status:"Dead Deal",Count:CountIf(Lead_Data,Status.Value="Dead Deal")});
        Collect(colDash_StatusTrack,{Status:"Completed Deal",Count:CountIf(Lead_Data,Status.Value="Completed Deal")}),
        
        ClearCollect(colDash_StatusTrack,{Status:"Not Started",Count:CountIf(Lead_Data,Status.Value="Not Started"&&Or(AssignedTo.Value=varUser,LeadMember1.Value=varUser,LeadMember2.Value=varUser,LeadMember3.Value=varUser))});
        Collect(colDash_StatusTrack,{Status:"In Progress",Count:CountIf(Lead_Data,Status.Value="In Progress"&&Or(AssignedTo.Value=varUser,LeadMember1.Value=varUser,LeadMember2.Value=varUser,LeadMember3.Value=varUser))});
        //Collect(colDash_StatusTrack,{Status:"Dead Deal",Count:CountIf(Lead_Data,Status.Value="Dead Deal"&&Or(AssignedTo.Value=varUser,LeadMember1.Value=varUser,LeadMember2.Value=varUser,LeadMember3.Value=varUser))});
        Collect(colDash_StatusTrack,{Status:"Completed Deal",Count:CountIf(Lead_Data,Status.Value="Completed Deal"&&Or(AssignedTo.Value=varUser,LeadMember1.Value=varUser,LeadMember2.Value=varUser,LeadMember3.Value=varUser))})
    );

// Collect Not Started & In Progress :::::: ACTIVE DEALS ::::::
    ClearCollect(colDash_ActiveDeals, Filter(Lead_Data,Status.Value="Not Started"));
    Collect(colDash_ActiveDeals, Filter(Lead_Data,Status.Value="In Progress"));

// Collect Dead Deals :::::: DEAD DEALS ::::::
    ClearCollect(colDash_DeadDeals, Filter(Lead_Data,Status.Value="Dead Deal"));

// Collect Completed Deals :::::: COMPLETED DEALS ::::::
    ClearCollect(colDash_CompletedDeals, Filter(Lead_Data,Status.Value="Completed Deal"));

// Allow sort by date to work
    Set(SortByDate,true);
    
// Have all data show on load of page
    Set(SelectedStatus, "All");


As previously mentioned and with your guidance I have my gallery Items set to

Sort(
    Filter(
        If(
            !IsEmpty(
                Filter(
                    Administrators,
                    FullName = varUser
                )
            ),
            Lead_Data,
            Filter(
                Lead_Data,
                AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser
            )
        ),
        If(
            "All" in SelectedStatus,
            //SelectedStatus = "All",
            true,
            Status.Value in SelectedStatus
        )
    ),
    "Created",
    If(
        SortByDate,
        Ascending,
        Descending
    )
)


And each one of my tabs (using "Not Started" as the example):

Set(SelectedStatus, "Not Started")


What I am trying to accomplish is that when I load the dashboard screen just Not Started and In Progress status rows display and when the user selects the Active Leads tab that currently is set to show all it will also only show Not Started and In Progress. This is where my confusion is coming in.

 

 

Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: Sorting My Dashboard and Displaying Only 2 Status Types of 4

Updating my understanding:

  • You have 4 tabs used for determining the SelectedStatus.
  • Each tab does one of these:
    Set(SelectedStatus, "Not Started");
    Set(SelectedStatus, "In Progress");
    Set(SelectedStatus, "Dead Deal");
    Set(SelectedStatus, "Completed Deal");
  • You create collections for a pie chart and different kinds of deals.
  • You raise a flag that would cause the gallery to show All.

 

It looks like SelectedStatus is text from what you have shared. In this case, we can keep things consistent across other formulas you have:

 

If(
    SelectedStatus = "All",
    true,
    Status.Value = SelectedStatus
)

or shortened:

 

 

Or(
    SelectedStatus = "All",
    Status.Value = SelectedStatus
)

 

 

Next, let's simplify a few parts to improve performance.

The part where you check if someone is an administrator is used twice. Let's store that in a variable on start of the app so you don't need to call it again. I'll be referring to it as varAdmin.

 

Set(varAdmin,
    !IsEmpty(
        Filter(
            Administrators,
            FullName = varUser
        )
    )
)

 

 

Confirm that this part works so far:

 

If(
    varAdmin,
    Lead_Data,
    Filter(
        Lead_Data,
        AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser
    )
)

 

 

In your gallery, you wrap Filter() around Filter().

 

Filter(Filter())

 

That may cause perf issues as one filter needs to be completed entirely before the next can begin. Let's place multiple conditions in the individual filters.

 

Multiple patterns--it's your choice. 

 

Filter(datasource, condition1 && condition2)

Filter(datasource, And(condition1,condition2))

Filter(datasource, condition1, condition2)

 

 

Below I merged the second condition. It's true that you would be repeating it, but it should work better. Confirm this is appearing the way you intend.

If(
    varAdmin,
    Filter(
        Lead_Data,
        Or(
            SelectedStatus = "All",
            Status.Value = SelectedStatus
        )
    ),
    Filter(
        Lead_Data,
        AssignedTo.Value = varUser || LeadMember1.Value = varUser || LeadMember2.Value = varUser || LeadMember3.Value = varUser || LeadMember4.Value = varUser,
        Or(
            SelectedStatus = "All",
            Status.Value = SelectedStatus
        )
    )
)

If so, append the Sort(). If it doesn't appear the way you expect, it may be the condition.

KimberlyM
Level 8

Re: Sorting My Dashboard and Displaying Only 2 Status Types of 4

@Mr-Dang-MSFT  Thank you! I really appreciate your time in showing me how to simplify what I have done! Shortening my If statement is very clever. I did change what I have to your suggestions as I am always looking to improve!

The thing I don't understand how to wrap my head around still is how to get my dashboard gallery to be displaying only 2 of 4 status types onVisible/Start as well as when the Show Active Leads button is clicked. I want it to load all of them but only display 2 of 4 of them. I only want to see Dead and Current Deals when I click on their tabs. Or maybe I am missing something all together. 

Power Apps Staff Mr-Dang-MSFT
Power Apps Staff

Re: Sorting My Dashboard and Displaying Only 2 Status Types of 4

Sorry I left out the most important part! 😅

 

If the changes I suggested are working, then the next thing to do is revise the second condition.

Currently what you have means, "If the SelectedStatus flag is "All", show everything; otherwise, show the matching status."

If(
    SelectedStatus = "All",
    true,
    Status.Value = SelectedStatus
)

To achieve showing either progress, you can add another case in your if:

If(
    SelectedStatus = "All", true,
    [active leads tab is selected], Or(Status.Value = "In Progress", Status.Value = "Not Started"),
    Status.Value = SelectedStatus
)

This means, "If the SelectedStatus flag is set to "All" show everything. If not, go to the next condition that checks if the Active Leads tab is selected. If so, then show the status matching In Progress or Not Started. Else show the one matching status.

 

So what you need to determine is how does the app know when the Active Leads tab is selected. Are you already using a variable to determine that state? For instance, OnSelect of that tab, do you have a Set statement for a variable for knowing that the tab had been clicked? If so, you can stick a variable there.

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (3,681)