Forum Discussion
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:
var combinetable = ADDCOLUMNS('Fact - Purchase Orders',"Requestor",RELATED(
'Dim - Purchase Requisitions'[Requisition Preparer]
),"Preparer",RELATED('RELATED('Dim - Purchase Orders'[PO Header Created By]
))
return
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
I know that there's a need for a pbix file but as said, it is analysis services.
Thank
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" )Table visual would not show the duplicated row if not put separate column in it:
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.
5 Replies
- amitchandakSuper 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]
))
returnCan you share sample data and sample output in table format?
- AnonymousNot applicable
Requester PO Creator Output
CGC CGC 1
CGC KLP 0
OTI OTI 1
OTI VLS 0
CGC CGC 1
VLS VLS 1
KLP 0This is some sample data, bear in mind the constraints mentioned on the initial message.
Thanks amitchandak- amitchandakSuper User
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))
- v-yingjlCommunity 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" )Table visual would not show the duplicated row if not put separate column in it:
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.