cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Convert Integer values into years in DAX (Tabular Model)

Hello 

I want to convert my interger column values into years using DAX fuincation in my tabular model . Please help me to do this.

 

Date1                       Date2                       Diff (In Days)            Expected Output 

01-01-2017              01-01-2016              365                           1

01-01-2017              01-01-2014              1096                         3

01-01-2017              31-12-2010              1097                         3.1

 

 

  

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Convert Integer values into years in DAX (Tabular Model)

@Parihar1980

 

You should create two calculated columns (YEAR) & second column with a SWITCH() function that corresponds to the Year such as if it is 2016, then 365 days etc..

 

Then simply divide the days column with a second column.

 

Thanks,

Bhavesh

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

2 REPLIES 2
Highlighted
Community Champion
Community Champion

Re: Convert Integer values into years in DAX (Tabular Model)

@Parihar1980

 

You should create two calculated columns (YEAR) & second column with a SWITCH() function that corresponds to the Year such as if it is 2016, then 365 days etc..

 

Then simply divide the days column with a second column.

 

Thanks,

Bhavesh

Thanks & Regards,
Bhavesh

Love the Self Service BI.
Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to give Kudos.

View solution in original post

Highlighted
Helper II
Helper II

Re: Convert Integer values into years in DAX (Tabular Model)

Thanks Bhavesh for your suggestion. I am also looking for Where condition in the DAX expression 

 

Select name , id from table where id=2  how to write it in DAX

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors