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.
I'm not sure why this works FINE
StartDato =
FORMAT(
CALCULATE(
MIN( 'nexus2 Fact_VisiteretTid'[Dato] );
ALL( 'nexus2 Fact_VisiteretTid' );
'nexus2 Fact_VisiteretTid'[VisitationId] = EARLIER( 'nexus2 Fact_VisiteretTid'[VisitationId] )
);"dd-mm-yyyy")
But this gives me a "can't compare type text with integer" error message:
StartDato2 =
var currentStartDate =
FORMAT(
CALCULATE(
MIN('nexus2 Fact_VisiteretTid'[Dato]);
ALL('nexus2 Fact_VisiteretTid');
'nexus2 Fact_VisiteretTid'[VisitationId] = EARLIER('nexus2 Fact_VisiteretTid'[VisitationId])
);"dd-mm-yyyy")
RETURN
IF(currentStartDate = 01-01-2015; 'nexus2 Fact_VisiteretTid'[Ikrafttraedelsesdato];currentStartDate)
What I'm trying to do is execute the first code, and if it's the 1st of january 2015, I need to return the value from another date column instead.
Any ideas?
Solved! Go to Solution.
And... I figured it out:
StartDato2 =
var currentStartDate =
FORMAT(
CALCULATE(
MIN('nexus2 Fact_VisiteretTid'[Dato]);
ALL('nexus2 Fact_VisiteretTid');
'nexus2 Fact_VisiteretTid'[VisitationId] = EARLIER('nexus2 Fact_VisiteretTid'[VisitationId])
);"dd-mm-yyyy")
RETURN
IF(currentStartDate = "01-01-2015"; FORMAT('nexus2 Fact_VisiteretTid'[Ikrafttraedelsesdato];"dd-mm-yyyy");currentStartDate)
The result of currentStartDate is text, meaning that the RETURN was setting text with a date [Ikrafttraedelsesdato], so I just needed to format that, and it's working now.
@grggmrtn Try adding quotes around the date: “01-01-2015". 01-01-2015 might be getting evaluated as math.
Almost?
StartDato2 =
var currentStartDate =
FORMAT(
CALCULATE(
MIN('nexus2 Fact_VisiteretTid'[Dato]);
ALL('nexus2 Fact_VisiteretTid');
'nexus2 Fact_VisiteretTid'[VisitationId] = EARLIER('nexus2 Fact_VisiteretTid'[VisitationId])
);"dd-mm-yyyy")
RETURN
IF(currentStartDate = "01-01-2015"; 'nexus2 Fact_VisiteretTid'[Ikrafttraedelsesdato];currentStartDate)
now gives me another error message:
"Expressions that yield variant data-type cannot be used to define calculated columns. "
😞
And... I figured it out:
StartDato2 =
var currentStartDate =
FORMAT(
CALCULATE(
MIN('nexus2 Fact_VisiteretTid'[Dato]);
ALL('nexus2 Fact_VisiteretTid');
'nexus2 Fact_VisiteretTid'[VisitationId] = EARLIER('nexus2 Fact_VisiteretTid'[VisitationId])
);"dd-mm-yyyy")
RETURN
IF(currentStartDate = "01-01-2015"; FORMAT('nexus2 Fact_VisiteretTid'[Ikrafttraedelsesdato];"dd-mm-yyyy");currentStartDate)
The result of currentStartDate is text, meaning that the RETURN was setting text with a date [Ikrafttraedelsesdato], so I just needed to format that, and it's working now.
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 |
---|---|
114 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |