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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
RMDNA
Solution Sage
Solution Sage

Simple issue: whole number comparison

All,

 

I'm trying to compare years between two tables, so I've separated the year out from the date type and set it to whole number datatype. I'm trying to create a simple column of "if this year doesn't equal the other year, then "Text" else "Text2".

 

In PowerQuery custom column, I've done:

 

if(
[Fiscal Year 1 Number] <> "Table 2"[Fiscal Year 2 Number]
)
then "Yes" else "No"

 

I get:

Expression.Error: We cannot apply field access to the type Text.
Details:
    Value=Table 2
    Key=Fiscal Year 2

 

Both fiscal year values are set to whole number. Any help?

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @RMDNA,

 

Is there any relationship between your Table 1 and Table 2? If there is a "Many to one" (*:1) relationship between Table 1 and Table 2, then you should be able to simply use the following DAX formula to add a calculate column in Table 1 under Modeling tab. Smiley Happy

 

New Column =
IF (
    'Table 1'[Fiscal Year 1 Number] <> RELATED ( 'Table 2'[Fiscal Year 2 Number] ),
    "Yes",
    "No"
)

model.PNG

 

Regards

MarcelBeug
Community Champion
Community Champion

I guess this code is in query "Table 1"?

 

If you want to refer to "Table 2" you need a # (#"Table 2"), but then again you are refering to a complete column in Table 2, or - in other words - to a list of values.

 

Somehow you need to get individual values, typically by merging the 2 tables so you have values from Table 1 on the same row as the values from Table 2. Then you can simply use:

if(
[Fiscal Year 1 Number] <> [Fiscal Year 2 Number]
)
then "Yes" else "No"

 

 

Specializing in Power Query Formula Language (M)

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.

Top Solution Authors