Forum Discussion
ricgin
10 years agoRegular Visitor
Days between two dates columns in DirectQuery
Hello community, I tried, unsuccesfuly, to subtract two date in DirectQuery but impossible.. How can I do this?
fpk81
2 years agoNew Member
Hi, so I found a way to make it work: First I change the type of the respective date column (e.g. [birthday]) from Date (or Date Time) to Whole number. Then create a new column with the formula DateTimeLocalNow(); I called it "NOW". After this change this column-type to a whole number as well (it needs to be an extra step). Then add a new colum eg "AGE" with a simple subtraction: "[NOW] - [birthday]". It will work with direct query and it will work, when opening visuals in powerbi online. Hope it helps! Please mark it as solution, if it works for you as well, THX!