ITLec / PowerQueryBuilder

13 stars 5 forks source link

Getting an error in PBI on date fields on custom entity #8

Open D365-ChadWeiner opened 6 years ago

D365-ChadWeiner commented 6 years ago

Hi Team,

Love the product so far.

I'm pulling data off a custom entity called snapshot that runs off the opportunity once a week to capture summary level data about the sales pipeline. There a two date fields showing the Close Date of the opportunity and date the snapshot record was taken.

The two columns have "error" in their columns when the query is executed in PowerBI.

image

This is the details of one of the Close Date issues. Not sure if there is something it didn't parse correctly.

image

Here is the FetchXML:

let GetResults = (z as text, x as number) => let S = Json.Document(Web.Contents(ServiceRootURL & "/new_opportunitysnapshots", [Headers=[Prefer="odata.include-annotations=*"],Query=[fetchXml=" <fetch page=""" & Text.From(x) & """ paging-cookie=""" & z & """> <entity name=""new_opportunitysnapshot""> <filter type=""and""><condition attribute=""edgw_businessunit"" operator=""eq"" value=""166930000"" /><condition attribute=""new_opportunityname"" operator=""not-like"" value=""%RENEWAL%"" /><condition attribute=""new_type"" operator=""in"">100000001100000000 "]])), P = try Xml.Document(S[#"@Microsoft.Dynamics.CRM.fetchxmlpagingcookie"]) otherwise null, R = if P <> null then List.Combine({S[value],@GetResults(Text.Replace(Text.Replace(Text.Replace(Uri.Parts("http://a.b?d=" & Uri.Parts("http://a.b?d=" & P{0}[Attributes]{1}[Value])[Query][d])[Query][d], ">", ">"), "<", "<"), """", """), x + 1)}) else S[value] in R, ResultsList = GetResults("", 1),

"Converted to Table" = Table.FromList(ResultsList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),

"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1",

                                    {
                                        "_new_customer_value",
                                        "_new_customer_value@OData.Community.Display.V1.FormattedValue",
                                        "_new_opportunity_value",
                                        "_new_opportunity_value@OData.Community.Display.V1.FormattedValue",
                                        "new_salesstage",
                                        "new_revenue",
                                        "new_closedate",
                                        "new_snapshotstatus",
                                        "new_snapshotstatus@OData.Community.Display.V1.FormattedValue",
                                        "new_rating",
                                        "new_type",
                                        "new_type@OData.Community.Display.V1.FormattedValue",
                                        "_ownerid_value",
                                        "_ownerid_value@OData.Community.Display.V1.FormattedValue",
                                        "new_snapshotdate",
                                        "edgw_businessunit",
                                        "edgw_businessunit@OData.Community.Display.V1.FormattedValue",
                                        "new_name",
                                        "edgw_opportunitycategory",
                                        "edgw_opportunitycategory@OData.Community.Display.V1.FormattedValue",
                                        "_edgw_practicearea_value",
                                        "_edgw_practicearea_value@OData.Community.Display.V1.FormattedValue",
                                        "edgw_totalquotacredit",
                                        "new_opportunitysnapshotid"
                                    }, 

                                    {
                                        "_new_customer_value",
                                        "_new_customer_value@OData.Community.Display.V1.FormattedValue",
                                        "_new_opportunity_value",
                                        "_new_opportunity_value@OData.Community.Display.V1.FormattedValue",
                                        "new_salesstage",
                                        "new_revenue",
                                        "new_closedate",
                                        "new_snapshotstatus",
                                        "new_snapshotstatus@OData.Community.Display.V1.FormattedValue",
                                        "new_rating",
                                        "new_type",
                                        "new_type@OData.Community.Display.V1.FormattedValue",
                                        "_ownerid_value",
                                        "_ownerid_value@OData.Community.Display.V1.FormattedValue",
                                        "new_snapshotdate",
                                        "edgw_businessunit",
                                        "edgw_businessunit@OData.Community.Display.V1.FormattedValue",
                                        "new_name",
                                        "edgw_opportunitycategory",
                                        "edgw_opportunitycategory@OData.Community.Display.V1.FormattedValue",
                                        "_edgw_practicearea_value",
                                        "_edgw_practicearea_value@OData.Community.Display.V1.FormattedValue",
                                        "edgw_totalquotacredit",
                                        "new_opportunitysnapshotid"
                                    }),
#"Renamed Columns" = Table.RenameColumns(#"Expanded Column1",
                                    {
                                        {"_new_customer_value", "Customer (new_customer)"},
                                        {"_new_customer_value@OData.Community.Display.V1.FormattedValue", "Customer"},
                                        {"_new_opportunity_value", "Opportunity (new_opportunity)"},
                                        {"_new_opportunity_value@OData.Community.Display.V1.FormattedValue", "Opportunity"},
                                        {"new_salesstage", "Sales Stage"},
                                        {"new_revenue", "Total Top Line Sale"},
                                        {"new_closedate", "Close Date"},
                                        {"new_snapshotstatus", "Snapshot Status (new_snapshotstatus)"},
                                        {"new_snapshotstatus@OData.Community.Display.V1.FormattedValue", "Snapshot Status"},
                                        {"new_rating", "Rating"},
                                        {"new_type", "Type (new_type)"},
                                        {"new_type@OData.Community.Display.V1.FormattedValue", "Type"},
                                        {"_ownerid_value", "Owner (ownerid)"},
                                        {"_ownerid_value@OData.Community.Display.V1.FormattedValue", "Owner"},
                                        {"new_snapshotdate", "Snapshot Date"},
                                        {"edgw_businessunit", "Business Unit (edgw_businessunit)"},
                                        {"edgw_businessunit@OData.Community.Display.V1.FormattedValue", "Business Unit"},
                                        {"new_name", "Name"},
                                        {"edgw_opportunitycategory", "Opportunity Category (edgw_opportunitycategory)"},
                                        {"edgw_opportunitycategory@OData.Community.Display.V1.FormattedValue", "Opportunity Category"},
                                        {"_edgw_practicearea_value", "Practice Area (edgw_practicearea)"},
                                        {"_edgw_practicearea_value@OData.Community.Display.V1.FormattedValue", "Practice Area"},
                                        {"edgw_totalquotacredit", "Total Quota Credit"},
                                        {"new_opportunitysnapshotid", "Pipeline Snap Shot"}
                                    }),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",

{ {"Customer (new_customer)", type text}, {"Customer", type text}, {"Opportunity (new_opportunity)", type text}, {"Opportunity", type text}, {"Sales Stage", type text}, {"Total Top Line Sale", type number}, {"Close Date", type date}, {"Snapshot Status (new_snapshotstatus)", type text}, {"Snapshot Status", type text}, {"Rating", type text}, {"Type (new_type)", type text}, {"Type", type text}, {"Owner (ownerid)", type text}, {"Owner", type text}, {"Snapshot Date", type date}, {"Business Unit (edgw_businessunit)", type text}, {"Business Unit", type text}, {"Name", type text}, {"Opportunity Category (edgw_opportunitycategory)", type text}, {"Opportunity Category", type text}, {"Practice Area (edgw_practicearea)", type text}, {"Practice Area", type text}, {"Total Quota Credit", type number}, {"Pipeline Snap Shot", type text} }) in

"Changed Type"

ITLec commented 6 years ago

Thanks a lot for your contribution, We have change some type handling. Next release will be within the next 24 hours. Please if you still facing the issue: let me know the type of both attributes

D365-ChadWeiner commented 6 years ago

Awesome. I’ll look for the update. Thanks for the reply.

Chad Weiner, MCSE | CRM Solution Architect m | 419-266-3684 e | chad.weiner@fullscope.commailto:chad.weiner@fullscope.com | fullscope.comhttp://www.fullscope.com/

From: Mohamed Rasheed Gomaa (ITLec) notifications@github.com Sent: Wednesday, July 18, 2018 8:52 AM To: ITLec/PowerQueryBuilder PowerQueryBuilder@noreply.github.com Cc: Chad Weiner chad.weiner@fullscope.com; Author author@noreply.github.com Subject: Re: [ITLec/PowerQueryBuilder] Getting an error in PBI on date fields on custom entity (#8)

Thanks a lot for your contribution, We have change some type handling. Next release will be within the next 24 hours. Please if you still facing the issue: let me know the type of both attributes

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ITLec/PowerQueryBuilder/issues/8#issuecomment-405959154, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AnOTk-Gz4WatAKqJENwvrni46NM3Vd54ks5uH0t4gaJpZM4VL0SL.

This e-mail and any files transmitted with it are confidential and are intended solely for the use of the individual or entity to whom they are addressed. This communication may contain information that is protected from disclosure by applicable law. If you are not the intended recipient, or the employee or agent responsible for delivering this communication to the intended recipient, be advised that you have received this e-mail in error and any use, dissemination, forwarding, printing or copying of this e-mail is strictly prohibited. If you believe that you have received this e-mail in error, please immediately notify Edgewater Technology by telephone at (781) 246-3343 and delete the communication from all e-mail files.

koenvb commented 6 years ago

Best solution for this, I had to do it also for each "Created On" field is to just convert your Date field from DateTime Timezone to Date and then for me it worked.

Sometimes it seems you first have to take this type of date you showed, convert it to DateTime zone and then as a second step convert it to Date.

Took me a while yesterday as well figuring out why I did not get any values when linking it to a date table but that fixed it for me.

@ITLec To what type would you convert it?