Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
I have this calculated field in Tableau that I am trying to convert into a calculated column in Power BI, but it is giving me a type error. I am going to use this calculated column to create other calculated column. What am I doing wrong? Any help would be greatly appreciated. Please see the codes below.
Tableau Code:
IF DATEPART('month',[DATE]) = DATEPART('month',TODAY())
and DATEPART('day',[DATE]) < DATEPART('day',TODAY())
then int((DateDiff('month',[DATE],(DATEADD('month', 0, TODAY()))))/12)
else int((DateDiff('month', [DATE],(DATEADD('month', -1, TODAY()))))/12) END
Power BI code:
yr = IF('Document'[DATE].[Month] = MONTH(NOW())
&& 'Document'[DATE].[Day] < TODAY(),
INT('Document'[DATE].[Month] - MONTH(NOW()))/12,
INT('Document'.[Month] - (MONTH(NOw()) -1))/12)
Solved! Go to Solution.
@Curious2115 , Try like
yr = IF( month('Document'[DATE])= MONTH(today())
&& day('Document'[DATE]) < day(TODAY()),
datediff('Document'[DATE] , MONTH(today()), month)/12,
datediff('Document'[DATE] , MONTH(eomonth(today(),-1)), month)/12)
or
yr = IF( month('Document'[DATE])= MONTH(today())
&& day('Document'[DATE]) < day(TODAY()),
datediff('Document'[DATE] , MONTH(today()), month)/12,
datediff('Document'[DATE] , MONTH(date(year(today()),month(today())-1,day(today()))), month)/12)
@Curious2115 , Try like
yr = IF( month('Document'[DATE])= MONTH(today())
&& day('Document'[DATE]) < day(TODAY()),
datediff('Document'[DATE] , MONTH(today()), month)/12,
datediff('Document'[DATE] , MONTH(eomonth(today(),-1)), month)/12)
or
yr = IF( month('Document'[DATE])= MONTH(today())
&& day('Document'[DATE]) < day(TODAY()),
datediff('Document'[DATE] , MONTH(today()), month)/12,
datediff('Document'[DATE] , MONTH(date(year(today()),month(today())-1,day(today()))), month)/12)
Thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
27 | |
20 | |
15 | |
12 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
18 |