Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
martinmatouy
Frequent Visitor

Push data with CSharp

Hi,

 

I'm working on getting my data-pushed with c# and the power bi API, my issue is with datetime columns; My explanation, in my code, when I created the dataset I'm specificating the type of my data, if the column is string, I'm sending string, when is Datetime I send DateTime, in this part my process work perfect ( O at less is what I think it is). When I'm tring to push the data, my datetime format is "yyyy-MM-ddTHH:mm:ss.fffZ" and when execute the push work fine, but in my power bi desktop the column isn't marked as datetime and when I try to work with a datetime function is telling me that cannot convert value text to date, this is the message.

 

martinmatouy_0-1593476749222.png

 

I'm assuming that my data isn't in the correct format in power bi dataset, what is driving me crazy.

If someone can give me the help I'll appreciate

 

Thanks for the help

 

9 REPLIES 9
martinmatouy
Frequent Visitor

Well, unfortunately, the issue was my CSharp code, I was sending the data type incorrectly.

 

I made the change to the data set creation process with the correct data type (Datetime) and It's working. I'm fighting now with the hierarchy of the dates fields because the streaming dataset isn't available but I have my original problem resolve.


Thank you so much for the time.

Anonymous
Not applicable

Hi,

I have the same issue, and I think PushDataSets have severe limitations, Data heirachy being one of them. I was never able to build a Date heirachy on the fly, and ended up creating the actual Dates in C# code.

Crappy solution, but works. 

 

phil

Thanks, Phil for your time; I agree with you in the serious limitations in the push dataset. In my case, I created in the c# the four values (year, month, day, and quarter) but seams the powerbi read as a number and when I use it the order is by number no for month. I'm questioning if the push dataset is working for me.

lbendlin
Super User
Super User

Power BI has a different type for that - it is called DateTimeZone. If it still doesn't work then you can replace the T by a space and remove the Z before converting to DateTime. (assuming that you want to keep your time as UTC)

 

Here's an example 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1MNM1sgwxNLUyMLcyMtEzMDCIUoqNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type datetimezone}})
in
    #"Changed Type"

Thanks, Ibendlin for your message, I tried removing the T between the date and the time and the Z at the end of my DateTime, but I still have the same message regarding the text type.

 

One thing I forgot to tell is that my data in my c sharp process, from a SQL Server DB.

 

I don't familiarize with the part of the code you tell me, can you explain a little more, please?

 

Thank again.

Did you try my example?  Test it with one of your strings.

Sorry lbendlin, I don't familiarize with that code, where should I run?

That is Power Query code. Run it in Excel or in Power BI Desktop.

Thanks again lbendlin, when I use my Desktop version, I'm unable to select an option, it looks like disabled.

 

martinmatouy_0-1593538337640.png

 

 

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors