web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sort Column for Lable ...
Power Apps
Unanswered

Sort Column for Lable value of calculated column inside gallery

(0) ShareShare
ReportReport
Posted on by 3,844 Super User 2025 Season 2

Hi all,

 

I have query reagrding powerapps,

i have powerapps gallery contains filter sort and all, here i have one label value that will be calculated for each rows, now i need to sort for this column.

Since lblGMonthsValuePI is actually a label name inside gallery label value is CountRows(ThisItem.Assigned_To_Group),

for each rows value will differer.

Reference i will add the code as well.

I will be using switch conditions for different conditions,

 

vIf(
 blnPhoneInventory = true,
 Switch(
 blnPISortColumn,
 "Assigned",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_assigned_to",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "Phones",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_phone_number",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "Telcode",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_telcode",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "Carrier",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_carrier",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "MonthsValue", // New case for sorting by calculated column
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "MonthsValue", // Sort by calculated value
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 // Default case if none of the above matches
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 )
 ),
 Switch(
 blnCalendarSortColumn,
 "Assigned",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_assigned_to",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "Phones",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_phone_number",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "Telcode",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_telcode",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "Carrier",
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "tisrpa_carrier",
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 "MonthsValue", // New case for sorting by calculated column
 SortByColumns(
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 ),
 "MonthsValue", // Sort by calculated value
 If(
 blnCalendarSort = true,
 SortOrder.Descending,
 SortOrder.Ascending
 )
 ),
 // Default case if none of the above matches
 Filter(
 colDormantPhoneData,
 And(
 Or(
 IsBlank(iptPersonNamePI.Text),
 iptPersonNamePI.Text in tisrpa_assigned_to
 ),
 Or(
 IsBlank(iptPhonePI.Text),
 iptPhonePI.Text in tisrpa_phone_number
 ),
 Or(
 IsBlank(iptTelCodePI.Text),
 iptTelCodePI.Text in tisrpa_telcode
 ),
 Or(
 IsBlank(iptCarriers.Text),
 iptCarriers.Text in tisrpa_carrier
 )
 )
 )
 )
)

 

 

Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    hey @Ahammad_Riyaz 

     

    can u try this:

    ClearCollect(
     colDormantPhoneDataWithMonthsValue,
     AddColumns(
     colDormantPhoneData,
     "MonthsValue", CountRows(ThisRecord.Assigned_To_Group)
     )
    );
    
    vIf(
     blnPhoneInventory = true,
     Switch(
     blnPISortColumn,
     "Assigned",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_assigned_to",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "Phones",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_phone_number",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "Telcode",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_telcode",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "Carrier",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_carrier",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "MonthsValue",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "MonthsValue",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     )
     ),
     Switch(
     blnCalendarSortColumn,
     "Assigned",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_assigned_to",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "Phones",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_phone_number",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "Telcode",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_telcode",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "Carrier",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "tisrpa_carrier",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     "MonthsValue",
     SortByColumns(
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     ),
     "MonthsValue",
     If(
     blnCalendarSort = true,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     ),
     Filter(
     colDormantPhoneDataWithMonthsValue,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     )
     )
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Verified answer
    WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    Hi @Ahammad_Riyaz ,

    You need AddColumns() as below - I have also compacted it to something that may be more manageable - Note your default sort also has to be included

    With(
     {
     _Data:
     Filter(
     colDormantPhoneData,
     And(
     Or(
     IsBlank(iptPersonNamePI.Text),
     iptPersonNamePI.Text in tisrpa_assigned_to
     ),
     Or(
     IsBlank(iptPhonePI.Text),
     iptPhonePI.Text in tisrpa_phone_number
     ),
     Or(
     IsBlank(iptTelCodePI.Text),
     iptTelCodePI.Text in tisrpa_telcode
     ),
     Or(
     IsBlank(iptCarriers.Text),
     iptCarriers.Text in tisrpa_carrier
     )
     )
     )
     },
     SortByColumns(
     AddColumns(
     _Data,
     MonthSort,
     CountRows(Assigned_To_Group)
     ),
     If(
     blnPhoneInventory,
     Switch(
     blnPISortColumn,
     "Assigned",
     "tisrpa_assigned_to",
     "Phones",
     "tisrpa_phone_number",
     "Telcode",
     "tisrpa_telcode",
     "Carrier",
     "tisrpa_carrier",
     "MonthsValue", 
     "MonthSort", 
     "YourDefaultColumnSortHere"
     ),
     Switch(
     blnCalendarSortColumn,
     "Assigned",
     "tisrpa_assigned_to",
     "Phones",
     "tisrpa_phone_number",
     "Telcode",
     "tisrpa_telcode",
     "Carrier",
     "tisrpa_carrier",
     "MonthsValue", 
     "MonthSort",
     "YourDefaultSortColumnHere"
     )
     ),
     If(
     blnCalendarSort,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Riyaz_riz11 Profile Picture
    3,844 Super User 2025 Season 2 on at
     "DefaulSortHere"

    Throwing error invalid column 

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @Ahammad_Riyaz ,

    As I mentioned, you need to put the name of your default sort column there (it will only trigger if none of the Switch options match, but you need something there)

  • Riyaz_riz11 Profile Picture
    3,844 Super User 2025 Season 2 on at

     

    With(
     {
     _Data1:
     Filter(
     ccsf_pim_department,
     And(
     Or(
     IsBlank(iptDepartmentName.Text),
     iptDepartmentName.Text in department_name
     )
     )
     )
     },
     SortByColumns(
     AddColumns(
     _Data1,
     PhoneSort,
     CountRows(
     GroupBy(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     ),
     tisrpa_assigned_to,
     tisrpa_phone_number,
     tisrpa_telcode,
     Assigned_To_Group
     )
    )
     MonthSort,CountRows(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     )
    ),CostSort,If(
     Sum(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     ),
     dormant_cost
     ) < 1,
     "$" & "0",
     "$" & Text(
     Sum(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     ),
     dormant_cost
     ),
     "###,###.##"
     ),
     If(
     blnDeptSortColumnDI,
     Switch(
     blnDeptSortDI,
     "Dept_name",
     "tisrpa_department_name",
     "PhoneCount",
     "PhoneSort",
     "MonthsC",
     "MonthsSort",
     "Cost",
     "CostSort",
     "Months", 
     "MonthSort",
     "Cost",
     "CostSort"
     ),
     Switch(
     blnDeptSortColumnDI,
     "Assigned",
     "tisrpa_assigned_to",
     "Phones",
     "tisrpa_phone_number",
     "Telcode",
     "tisrpa_telcode",
     "Carrier",
     "tisrpa_carrier",
     "Months", 
     "MonthSort",
     "Cost",
     "CostSort"
     )
     ),
     If(
     blnDeptSortDI,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     )
    )

     I tried similar type but getting error can you please help on this.

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @Ahammad_Riyaz ,

    What is the error ?

  • Riyaz_riz11 Profile Picture
    3,844 Super User 2025 Season 2 on at

    This.item we can't give, is it possible to reformat. Am struck how to resolve this issue, here lookup also there for department id.

     

     

  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at

    @Ahammad_Riyaz ,

    Without seeing your data, it is a bit hard, but this structure may be in the right direction. You also had some bracketing issues (easier to pick up if indented as below)

    With(
     {
     _Data1:
     Filter(
     ccsf_pim_department,
     Or(
     IsBlank(iptDepartmentName.Text),
     iptDepartmentName.Text in department_name
     )
     )
     },
     SortByColumns(
     AddColumns(
     _Data1,
     PhoneSort,
     CountRows(
     GroupBy(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = id
     ),
     tisrpa_assigned_to,
     tisrpa_phone_number,
     tisrpa_telcode,
     Assigned_To_Group
     ),
     MonthSort,
     CountRows(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = id
     )
     ),
     CostSort,
     If(
     Sum(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = id
     ),
     dormant_cost
     ) < 1,
     "$0",
     "$" & 
     Text(
     Sum(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = id
     ),
     dormant_cost
     ),
     "###,###.##"
     )
     )
     ),
     If(
     blnDeptSortColumnDI,
     Switch(
     blnDeptSortDI,
     "Dept_name",
     "tisrpa_department_name",
     "PhoneCount",
     "PhoneSort",
     "MonthsC",
     "MonthsSort",
     "Cost",
     "CostSort",
     "Months", 
     "MonthSort",
     "Cost",
     "CostSort"
     ),
     Switch(
     blnDeptSortColumnDI,
     "Assigned",
     "tisrpa_assigned_to",
     "Phones",
     "tisrpa_phone_number",
     "Telcode",
     "tisrpa_telcode",
     "Carrier",
     "tisrpa_carrier",
     "Months", 
     "MonthSort",
     "Cost",
     "CostSort"
     )
     ),
     If(
     blnDeptSortDI,
     SortOrder.Descending,
     SortOrder.Ascending
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Riyaz_riz11 Profile Picture
    3,844 Super User 2025 Season 2 on at

    This is not working Actually i have 2 tables in dataverse,

    department and phones, phone table deptcode is lookup into department table deptcode column.

    sort icon onslect

    Ahammad_Riyaz_2-1719208632448.png

     

    this is the front screen visibility.

    Ahammad_Riyaz_1-1719208268836.png

     

    ThisItem.department_name
    
    
    CountRows(
     GroupBy(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     ),
     tisrpa_assigned_to,
     tisrpa_phone_number,
     tisrpa_telcode,
     Assigned_To_Group
     )
    )
    
    
    CountRows(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     )
    )
    
    
    If(
     Sum(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     ),
     dormant_cost
     ) < 1,
     "$" & "0",
     "$" & Text(
     Sum(
     Filter(
     ccsf_pim_dormant_phone,
     ccsf_pim_department_id.id = ThisItem.id
     ),
     dormant_cost
     ),
     "###,###.##"
     )
    )

     

     

    Here is the code for gallery items for each label.

    Now i need to filter and sort those columns

    ccsf_pim_dormant_phone and ccsf_pim_department are table names.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard