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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
WAB_Reports
Helper I
Helper I

Is this a bug or is my function/transform wrong?

Hello all,

 

In my PowerQuery, I have two columns that do the following: Age = duration between 2 dates,  JustAgeInDays = text to the left of the "." in Age.  In the sample screen shot below, you can see the highlighted value "0.00:00:00" in Age, which should then translate to "0" in the JustAgeInDays column.  However, it does not, but instead it returns "00:00:00", which in turn throws an "ERROR" when I transform the column into type "Int.64". 

 

image.png

 

Function to select left of the "."

 

image.png

 

Function to transform text from above to Int64 

 

image.png

 

Is this a bug or am I wrong in thinking the 0 should be populated? If it is not a bug, or if there is a better way to in just one function, take the difference in days as a numerical value?

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2 ACCEPTED SOLUTIONS
PaulDBrown
Community Champion
Community Champion

@WAB_Reports 

 

I'm not sure how you have calculated the "Age" (there is a function in Power Query which does this for you).

Age function.jpg

The code for this is:

M code.JPG

 SO if you need to calculate a difference between two date columns, just change the M code for the columns highlighted in yellow. (notice how the type is duration).

In your example, if you select your  "Age" column (set it to type duration first), there is a function which calculates the age in "total days" (here it is with the corresponding code).

Age in days.jpgdays calc.JPG





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

v-kelly-msft
Community Support
Community Support

Hi  @WAB_Reports ,

 

Based on my test,it's ok to use "Text.beforedelimiter" function in power query to get the value you need:

Screenshot 2020-10-05 155504.png

But you should be sure that the Age column is a text format.

If your issue still exists ,would you pls upload your .pbix file to onedrive business and share the link with us?

Remember to remove the confidential information.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi  @WAB_Reports ,

 

Based on my test,it's ok to use "Text.beforedelimiter" function in power query to get the value you need:

Screenshot 2020-10-05 155504.png

But you should be sure that the Age column is a text format.

If your issue still exists ,would you pls upload your .pbix file to onedrive business and share the link with us?

Remember to remove the confidential information.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

PaulDBrown
Community Champion
Community Champion

@WAB_Reports 

 

I'm not sure how you have calculated the "Age" (there is a function in Power Query which does this for you).

Age function.jpg

The code for this is:

M code.JPG

 SO if you need to calculate a difference between two date columns, just change the M code for the columns highlighted in yellow. (notice how the type is duration).

In your example, if you select your  "Age" column (set it to type duration first), there is a function which calculates the age in "total days" (here it is with the corresponding code).

Age in days.jpgdays calc.JPG





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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