Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Comparing values of type Date with values of type Text

Hi

I have this piece of code below that seems to be syntactically correct but I get an error when I try to visualise. I tried using FILTER and VALUE but in vain.


Error Message:
DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

My DAX code below and you can see I am not comparing Text with Date but if this is not the right way please can someone put me in the right direction:

Prev_RC =
VAR Week = calculate(SUM(E[RC]), DATEADD(Dt[DateFrom], -7, DAY))
VAR Month = calculate(SUM(E[RC]), DATEADD(Dt[DateFrom], -1, Month))

return

if(SELECTEDVALUE(Dt[DateFrom]) = "Week",
Week,
Month
)

 

Sample Data:

24,986
63,180
84,050

 

Relationship (joined with field name Key_Dates)
[Dt] 1.* [E]

 

 

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

I have a little confused about your scenario.

Based on your formula, the [DateFrom] should be a date type column. 

However, you code below seems to be a text type column.

if(SELECTEDVALUE(Dt[DateFrom]) = "Week",
Week,
Month
)

If it is convenient, could you share your data sample which could reproduce your scenario so that I could copy and have a test on it.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

I have a little confused about your scenario.

Based on your formula, the [DateFrom] should be a date type column. 

However, you code below seems to be a text type column.

if(SELECTEDVALUE(Dt[DateFrom]) = "Week",
Week,
Month
)

If it is convenient, could you share your data sample which could reproduce your scenario so that I could copy and have a test on it.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Yes, that's right. That was so silly of me. I was comparing the wrong field.

Thank you


@v-piga-msft wrote:

Hi @Anonymous ,

I have a little confused about your scenario.

Based on your formula, the [DateFrom] should be a date type column. 

However, you code below seems to be a text type column.

if(SELECTEDVALUE(Dt[DateFrom]) = "Week",
Week,
Month
)

If it is convenient, could you share your data sample which could reproduce your scenario so that I could copy and have a test on it.

Best  Regards,

Cherry

 


 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.