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

Compare 2 string columns in Analysis services using DAX

Hello world, 
so I have been using analysis services in power bi and I want to compare 2 string columns. 
The 2 string columns come from different DIM tables of the model, that are being combined through a FACT table. 
I want to compare those two columns somehow, but unfortunately , no matter what I've tried didn't work. 
Initially I used this:

 
Table 2 =
var combinetable = ADDCOLUMNS('Fact - Purchase Orders',"Requestor",RELATED(
'Dim - Purchase Requisitions'[Requisition Preparer]
),"Preparer",RELATED('RELATED('Dim - Purchase Orders'[PO Header Created By]
))
return
 
in order to combine those two columns in a table and the somehow with an if make the comparison, but unforunately it doesn't work.
Any ideas?
I have no access to change the model (as said, analysis services) so I can only work with DAX. 
The three tables are
Dim - Purchase Orders
Dim - Purchase Requisitions
Fact - Purchase Orders
The point is to see if the Requisition Preparer (from Dim - Purchase Requisition) is the same with the PO Header Created by (from Dim Purchase Orders).

I know that there's a need for a pbix file but as said, it is analysis services.
Thank
1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

If you have columns like [ID] to create relationships between two tables, you can try to create a measure like this and set the visual filter:

Check = 
IF (
    CONTAINS (
        VALUES ( 'Table11'[Requester] ),
        'Table11'[Requester], SELECTEDVALUE ( Table22[PO Creator] )
    ),
    "OK",
    "Not OK"
)

1.png

Table visual would not show the duplicated row if not put separate column in it:

2.png

 

Best Regards,
Community Support Team _ Yingjie Li
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

5 REPLIES 5
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

If you have columns like [ID] to create relationships between two tables, you can try to create a measure like this and set the visual filter:

Check = 
IF (
    CONTAINS (
        VALUES ( 'Table11'[Requester] ),
        'Table11'[Requester], SELECTEDVALUE ( Table22[PO Creator] )
    ),
    "OK",
    "Not OK"
)

1.png

Table visual would not show the duplicated row if not put separate column in it:

2.png

 

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

 

amitchandak
Super User
Super User

@Anonymous , Try like

Table 2 =
var combinetable = ADDCOLUMNS('Fact - Purchase Orders',"Requestor",RELATED(
'Dim - Purchase Requisitions'[Requisition Preparer]
),"Preparer",RELATED('Dim - Purchase Orders'[PO Header Created By]
))
return

 

Can you share sample data and sample output in table format?

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Requester     PO Creator    Output

CGC               CGC                1

CGC               KLP                 0

OTI                OTI                  1

OTI                VLS                  0

CGC              CGC                 1
VLS               VLS                  1
KLP                                       0

 

This is some sample data, bear in mind the constraints mentioned on the initial message. 
Thanks @amitchandak 

@Anonymous , Try a measure like where 'Fact - Purchase Orders'[ID] is there level where you want to compare these names, replace with the correct name 

 

New measure = countx(values('Fact - Purchase Orders'[ID]),If( RELATED('Dim - Purchase Requisitions'[Requisition Preparer]) =RELATED('Dim - Purchase Orders'[PO Header Created By]) ,1,0))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Could this also be changed to show instead of 1 and 0, "OK" & "Not OK", as I've tried it and still shows numbers

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.