'How can I sort gallery based on multiple columns in power automate?

I tried below query but it is working only for first condition.

SortByColumns(
    Filter(
        [@Questions],
        'Discussion Type'.Value = "Question" Or 'Discussion Type'.Value = "Conversation",
        StartsWith(
            Title,
            TextSearchBox1.Text
        )
    ),
    "Title",If(
        SortTitle,
        Descending,
        Ascending
    ),
    "Created",If(
        SortDate,
        Descending,
        Ascending
)

)

I have created a container with 2 items 'Sort alphabetically' or'Sort by CreatedDate' but the query is not working.

Visible property of Item 1: UpdateContext({SortDate: !SortDate})

Visible property of Item 2: UpdateContext({SortTitle: !SortTitle})



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source