Forum Discussion
BjoernSchaefer
Helper II
5 years agoMonths / Years in Contract
Hello everybody, i'm dealing with a challenge right now. I have one table that looks like this ...
- 5 years ago
you can try to use below DAX to create two columns for year and month. However, I can't get your explaination of value column.
month = VAR _start=minx(FILTER('Table (2)','Table (2)'[contract]=EARLIER('Table (2)'[contract])),'Table (2)'[Date_invoice]) VAR _month=DATEDIFF(_start,'Table (2)'[Date_invoice],MONTH)+1 return if(_month>12,if(mod(_month,12)=0,12,mod(_month,12)),_month) year = VAR _start=minx(FILTER('Table (2)','Table (2)'[contract]=EARLIER('Table (2)'[contract])),'Table (2)'[Date_invoice]) VAR _month=DATEDIFF(_start,'Table (2)'[Date_invoice],MONTH)+1 return if(mod(_month,12)=0,int(DIVIDE(_month,12)),int(DIVIDE(_month,12))+1)Btw, it will be better if you can share your sample data.
BjoernSchaefer
Helper II
5 years agothank you very much for that. Works like a charm. You made my day. Have a good one.
Regards
Björn
ryan_mayu
Super User
5 years agoyou are welcome