Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
I'm trying to display days in years. For example 405 days is 1 year, 1 month.
Solved! Go to Solution.
Let's say you store your number of days in the [Number of days] measure. Here's one way of doing it:
Days in years = VAR Days = [Number of days] VAR Years = ROUNDDOWN(Days/365,0) VAR Months = ROUNDDOWN((Days - Years * 365)/30.5,0) VAR sYear = IF(Years = 1, "", "s") VAR sMonth = IF(Months = 1, "", "s") VAR YearPart = IF(Years<1,"",Years & " year" & sYear & ", ") VAR MonthPart = IF(Months<1, "", Months & " month" & sMonth) RETURN IF(AND(Years=0,Months=0), Days & " day" & IF(Days=1, "", "s"),YearPart & MonthPart)
Sample output:
Let's say you store your number of days in the [Number of days] measure. Here's one way of doing it:
Days in years = VAR Days = [Number of days] VAR Years = ROUNDDOWN(Days/365,0) VAR Months = ROUNDDOWN((Days - Years * 365)/30.5,0) VAR sYear = IF(Years = 1, "", "s") VAR sMonth = IF(Months = 1, "", "s") VAR YearPart = IF(Years<1,"",Years & " year" & sYear & ", ") VAR MonthPart = IF(Months<1, "", Months & " month" & sMonth) RETURN IF(AND(Years=0,Months=0), Days & " day" & IF(Days=1, "", "s"),YearPart & MonthPart)
Sample output:
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 45 | |
| 41 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 67 | |
| 33 | |
| 31 | |
| 29 |