Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I`m using the DATEDIFF function and I`m getting the expected results in number of days.
What I`m not being able to do is to display the days in a more textual form. For example, If I have the number 398 days, I want to display " 1 year, 1 month and 3 days".
Ideally, I would like to use plurals/singular on Years Months and Days everytime it is applicable.
I've been struggling with that bu couldn't find any particular approach to make it work.
Tks!
Solved! Go to Solution.
Try this example
DateText =
var _fulldays= 35
//replace 35 with your measure
var _year= QUOTIENT(_fulldays,365)
var _month= QUOTIENT(MOD(_fulldays,365),30)
var _day= MOD(MOD(_fulldays,365),30)
var _yearText = IF(_year=1,"1 year",IF(_year>1,_year&" years",BLANK()))
var _monthText= IF(_month=1,"1 month",IF(_month>1,_month&" months",BLANK()))
var _dayText= IF(_day=1,"1 day",IF(_day>1,_day&" days",BLANK()))
var _finalText= _yearText&" "&_monthText&" "&_dayText
return _finalText
You may have to tweak the code a little bit.
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
Try this example
DateText =
var _fulldays= 35
//replace 35 with your measure
var _year= QUOTIENT(_fulldays,365)
var _month= QUOTIENT(MOD(_fulldays,365),30)
var _day= MOD(MOD(_fulldays,365),30)
var _yearText = IF(_year=1,"1 year",IF(_year>1,_year&" years",BLANK()))
var _monthText= IF(_month=1,"1 month",IF(_month>1,_month&" months",BLANK()))
var _dayText= IF(_day=1,"1 day",IF(_day>1,_day&" days",BLANK()))
var _finalText= _yearText&" "&_monthText&" "&_dayText
return _finalText
You may have to tweak the code a little bit.
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |