cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

missing columns not returned when iterate through web service

I'm calling a SOAP API in XML to pull down a report into Power Query. The query iterates through a list of locations stored in a manual table. The problem I have is when the location doesn't have a value for a column, it doesn't return the column at all. This is resulting in the power query erroring out when it can't find the column. I'm assuming I need to define the elements using something like an element path, but I'm clueless on how to do that in the XML. Can anyone help please?

 

For example, I'm getting this error:

 

An error occurred in the ‘’ query. Expression.Error: The column 'MoveIn' of the table wasn't found.
Details:
    MoveIn

 

Here's the query:

(AllLocations) as table =>

let

MTDBegin = DateTime.ToText(Date.StartOfMonth(DateTime.LocalNow()), "yyyy-MM-ddT00:00:00"),
MTDEnd = DateTime.ToText(DateTime.LocalNow(), "yyyy-MM-ddThh:mm:ss"),

    Source = Xml.Tables(Web.Contents("https://.../...Ws.asmx?WSDL"

    ,[Content=Text.ToBinary("<soapenv:Envelope xmlns:soapenv="&Character.FromNumber(34)&"http://schemas.xmlsoap.org/soap/envelope/"&Character.FromNumber(34)&" xmlns:rep="&Character.FromNumber(34)&"http:/.../ReportingWs"&Character.FromNumber(34)&">
     <soapenv:Header/>
   <soapenv:Body>
      <rep:MoveInsAndMoveOuts>

         <!--Optional:-->
         <rep:sLocationCode>"&AllLocations&"</rep:sLocationCode>
         <!--Optional:-->
         <rep:sCorpUserName>...</rep:sCorpUserName>
         <!--Optional:-->
         <rep:sCorpPassword>...</rep:sCorpPassword>
         <rep:dReportDateStart>"&MTDBegin&"</rep:dReportDateStart>
         <rep:dReportDateEnd>"&MTDEnd&"</rep:dReportDateEnd>
      </rep:MoveInsAndMoveOuts>
   </soapenv:Body>

</soapenv:Envelope>"),Headers=[#"Accept-Encoding"="gzip,deflate", #"Content-Type"="text/xml;charset=UTF-8"]])),
    Table = Source{0}[Table],
    Table3 = Table{0}[Table],
    Table4 = Table3{0}[Table],
    Table5 = Table4{0}[Table],
    Table6 = Table5{1}[Table],
    Table7 = Table6{0}[Table],
    Table8 = Table7{0}[Table],
    Table9 = Table8{0}[Table],
    Table10 = Table9{0}[Table],
    #"Changed Type" = Table.TransformColumnTypes(Table10,{{"SiteID", Int64.Type}, {"MoveIn", Int64.Type}, {"MoveOut", Int64.Type}, {"Transfer", Int64.Type}, {"MoveDate", type datetimezone}, {"UnitName", type text}, {"TenantName", type text}, {"Width", type number}, {"Length", type number}, {"UnitSize", type text}, {"StandardRate", type number}, {"MovedInArea", type number}, {"MovedInRentalRate", type number}, {"MovedInVariance", type number}, {"MovedInDaysVacant", Int64.Type}, {"MovedOutArea", type number}, {"MovedOutRentalRate", type number}, {"MovedOutVariance", type number}, {"MovedOutDaysRented", Int64.Type}, {"Address", type text}, {"City", type text}, {"Region", type text}, {"PostalCode", Int64.Type}, {"dcDiscount", type number}, {"iLeaseNum", Int64.Type}, {"dRentLastChanged", type datetimezone}, {"sEmpInitials", type text}, {"TenantID", Int64.Type}, {"iAuctioned", Int64.Type}, {"dcPushRateAtMoveIn", type number}, {"dcStdRateAtMoveIn", type number}, {"bPower", type logical}, {"bClimate", type logical}, {"bAlarm", type logical}, {"bInside", type logical}, {"sUnitType", type text}, {"iDaysSinceMoveOut", Int64.Type}, {"dcAmtPaid", type number}, {"InquiryEmployeeID", Int64.Type}, {"CorpUserID_ConvertedToMoveIn", Int64.Type}})

in
#"Changed Type"

 

 

1 REPLY 1
Microsoft
Microsoft

@cleon169,

I note that the #"Changed Type" step metions the 'MoveIn' column. When your table doesn't have this column, the above error will throw. Please delete the "Change Type" step under "APPLED STEPS" in Query Editor of Power BI Desktop.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
secondImage

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

secondImage

Power BI Women

Join our monthly meetings and learning sessions.

secondImage

Congratulations!

We are excited to announce the Power BI Super Users!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors