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
Anonymous
Not applicable

Remove no of days from Date with DAX

Hi All,


The requirement is i have to remove days(Time) from Date column with DAX(calculated column or measure)
Time Column - Text
Date Column - Date(dd-mm-yy)

Example - if the Time column has 2,00 days,  Date colum (17th Jan 22) = 17th jan 22-3days
the output should come - 15th Jan 22
Any advise please?

LikhithaVG123_0-1672125206521.png

Thanks

1 ACCEPTED SOLUTION

I see, 

the issue is with the format ",00" the most direct way to solve this would be to change the columns data type to number. Here is an dax alternative:

Measure 30 =
var _date = MAX('Table (19)'[Column1])
var _diff = value(max('Table (19)'[Column2]))/100
return

_date-_diff

The 14,00 is converted for example to 1400 with VALUE and this is why your numbers don't match.
ValtteriN_0-1672142325273.png

 








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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ValtteriN
Super User
Super User

Hi,

You can use e.g. MAX/SELECTEDVALUE combined with a simple subtraction:

ValtteriN_1-1672126370836.png

dax:

Measure 30 =
var _date = MAX('Table (19)'[Column1])
var _diff = MAX('Table (19)'[Column2])
return

_date - _diff

ValtteriN_2-1672126406464.png

 


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




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

Proud to be a Super User!




Anonymous
Not applicable

Hi @ValtteriN 

Thanks for the solution. But can we convert same measure to calculated column?
beacuse when i am creating Measure . i am getting circular dependency error (if we use combination of more calcu,ated columns and measures their might be circular dependency) to avoid can we convert same measure to calculated column ??

i have tried to convert same into calculated column but it is giving incorrect result

 

Please advise

Anonymous
Not applicable

Hi ValtteriN
I have tried your formula - Getting incorrect result as below screenshot
Pleae advise further.

LikhithaVG123_0-1672140406238.png
Thanks

 

 

I see, 

the issue is with the format ",00" the most direct way to solve this would be to change the columns data type to number. Here is an dax alternative:

Measure 30 =
var _date = MAX('Table (19)'[Column1])
var _diff = value(max('Table (19)'[Column2]))/100
return

_date-_diff

The 14,00 is converted for example to 1400 with VALUE and this is why your numbers don't match.
ValtteriN_0-1672142325273.png

 








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

Proud to be a Super User!




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.