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 / Converting Integer col...
Power Apps
Unanswered

Converting Integer column to Text in Powerapps

(0) ShareShare
ReportReport
Posted on by 1

Hi Champions 

Need your help!

I have a column 'JobIdInt' which is integer type coming to PowerApps UI from SQL Views. 
I have one more column 'JobId' which we converted to varchar in views in SQL, 
I have Search and sorting controls/Icons are there in UI. currently I am using JobId column for searching and JobIdInt for sorting. due to this I need to maintain 2 fields which is not correct. 

So, from UI, for searching I want to use the JobIdInt column to sort and search. I tried multiple ways to converting this field to Text format, but it is failing. 

attempts I tried 

1. Using the Text function directly within the Search function:

Search(Gallery_JS.AllItems,SearchJobStatus_1.Text,"TriggredBy", "Source", "Status", Text(JobIdInt))

2. Adding a new column with the name "JobIdIntText" and converting JobIdInt to text:
AddColumns(Gallery_JS.AllItems,"JobIdIntText", Text(JobIdInt))

3. Trying to directly use "JobIdIntText" within the Search function:
Search(Gallery_JS.AllItems,SearchJobStatus_1.Text,"TriggredBy", "Source", "Status", "JobIdIntText")
4. Adding a new column inline within the Search function:

Search(AddColumns(Gallery_JS.AllItems,"JobIdIntText", Text(JobIdInt)),SearchJobStatus_1.Text,"TriggredBy", "Source", "Status", Text(JobIdInt))
5. Attempting to use Value function to get the column name:
Search(Gallery_JS.AllItems,SearchJobStatus_1.Text,"TriggredBy", "Source", "Status", Value("JobIdInt"))
etc........
Can you please help me to how to convert this into Text for searching. 

 

Categories:
I have the same question (0)
  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    Hi @RG7 

    The syntax you use would look like this:

    SortByColumns(
     Search(YourSQLView,
     SearchJobStatus_1.Text,
     "TriggredBy", "Source", "Status", "JobId"
     ),
     "JobIdInt",
     SortOrder.Ascending
    )

    Note that you would pass the SQLView to the Search function, not the AllItems property of the gallery.

    The Search function would include the varchar version of JobId, and the SortByColumns function would operate on the int value (JobIdInt)

     

  • MS007 Profile Picture
    6 on at

    Hi @timl 
    I've implemented search functionality in our Gallery items, but I'm encountering an issue with sorting the "JobId" column, which has a varchar datatype. I tried converting "JobId" to an integer for sorting purposes using the following script:

    ClearCollect(
     ConvertedItems,
     AddColumns(
     View_JobStatus, // Make sure this is your actual data source
     "JobIdInt2", Value(JobId) // Properly convert JobId from varchar to integer
     )
    );
    
    Set(
     sortedItems,
     SortByColumns(
     ConvertedItems,
     "JobIdInt2",
     varSortDirection // Use the current sort direction for sorting
     )
    );
    
    // Update the sort direction for the next time
    UpdateContext({
     varSortDirection: If(varSortDirection = SortOrder.Ascending, SortOrder.Descending, SortOrder.Ascending)
    });



    // In the App's OnStart property

    Set(varSortDirection, SortOrder.Ascending);


    Despite this, the "JobId" sorting still appears as: 12, 21, 3, 312, 333. It seems that the numerical sorting isn’t being applied as expected. Could you help me adjust the script so that the "JobId" sorts correctly as numerical values?

    Thanks,
    MS



  • timl Profile Picture
    36,383 Super User 2025 Season 2 on at

    In the formula that you've posted, sortedItems should be sorted by the JobIdInt2 column. Are you sure you've set the Items property of your gallery to sortedItems?

     

  • MS007 Profile Picture
    6 on at

    hi @timl ,
    Yes, the Items property of the gallery is sortedItems.

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