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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Collection using local...
Power Apps
Unanswered

Collection using local sql - data types

(0) ShareShare
ReportReport
Posted on by 185

I have an app that Collects data from a local Gateway SQL table into a Powerapps collection. When I try to add a new row to the collection, I get an error that the data types do not match.

1.jpg

I have narrowed it down to a date field.  If I export the app and view the JSON Entities file, it shows me that when I collect from SQL, the date field has a data type of "lowercase d".  However, when I try to Collect and add a new row to the collection, the data type is "uppercase D".  I have tried many things... changing the datatype in SQL from datetime to: date, datetime2, and dateoffset.  On the PowerApps side, I have tried using the date control's SelectedDate, using a string, using the DateValue of a string.  Obviously the string won't work, but the other two both have a data type of "uppercase D".

2.jpg

 

When trying to update from Collection inside of PowerApps, this is the data type:

3.jpg

I cannot get anything to update the collection. What am I missing or not understanding?

 

Any help is greatly appreciated.

 

Categories:
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @TML,

     

    How do you create the collection within your app?

    Further, how do you add a new row to the collection that you created? Could you please share a bit more about the formula within your app?

     

    I have made a test on my side, and don't have the issue that you mentioned.

     

    The error message told that there is a data type mismatch issue within the formula that you use to add a new row to the connection. The DateReporting column is a datetime type column, but the dteReportingDate.SelectedDate formula returns a Date value.

     

    Please take a try to format the date value (dteReportingDate.SelectedDate) that you provided for the DateReporting column into a datetime value, and then check if the issue is solved.

     

    Please take a try to modify your formula as below:

    Collect(
    Collection1,
    {
    CareTaker:"",
    Comments:"",
    DateReporting:DateTimeValue(Text(dteReportingDate.SelectedDate)),
    FarmCode:"",
    ...

    }
    )

    Note: The Collection1 represents the Collection that you created within your app, which collects data from your local Gateway SQL table.

     

    Best regards,

    Kris

  • TML Profile Picture
    185 on at

    When the app's first screen opens, it reads in existing data from the SQL table.  Below is the code:

     ClearCollect(
    DCIRecords,
    SortByColumns(
    Filter(
    AddColumns(
    '[dbo].[DCI]',"NeedsSync",false),
    FarmCode=gFCode),
    "DateReporting",
    Descending));

     

    Later in the app when it is determined that I need to add a row to the Collection, I use this code:

    Collect(DCIRecords,
     { FCode: gFCode,
     DateReporting: DateValue(vSelectedDate),
     Room: vRoom,
     HighTemp: vHTemp,
     LowTemp: vLTemp,
     TempSetPoint: vTempSetPt,
     WaterMeterUsage: vWaterUsage,
     Comments: vComments,
     NeedsSync: gNeedsSync
     }
    );

    I have also tried using dteReportingDate.Selected date and either way it give me the same outcome.  I have also changed the data type in the SQL column and have tried DateTime, DateTime2, Date, and DateOffset.  All have the same outcome and think their is a data type mismatch.

     

  • TML Profile Picture
    185 on at

    Is there documentation that explains the letter codes for the different data types?

  • TML Profile Picture
    185 on at

    I also tried just now using DateValue and the string date, and concatenated a time to it as well and still have the same results.

  • TML Profile Picture
    185 on at

    Does this mean no one can answer the question or help me solve the problem?

  • joeyb1215 Profile Picture
    15 on at

    Don't know if you are still looking for an answer, but I just recently had this issue and solved it. I have a Gallery full of Jobs that change colors if they are updated with any information. So when a change is made to a Job, it collects the "Job Number" as JOBNUM and a "Work Type" as WRKTYPE in a collection. So I first tried the fill color to read If Lookup(Collection, JOBNUM =Thisitem.Job # & WRKTYPE=ThisItem.Work Type), change to Green. I was getting an Invalid Argument Error stating that Work Types were different data types(I tried Value() and Text() functions and was still unsuccessful). So then I tired collecting  "Job Number&Work Type" as JOBNUM, and when I referenced IF JOBNUM=ThisItem.Job Number&Work Type it worked. Hope that helps. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard