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
flyingfox
Regular Visitor

Looking for records where two variables are swapped

Hi, I am trying to figure out how to implement this scenario with DAX.

Consider the following matrix with three columns

idparametercost

AB

Parameter 1

10

AC

Parameter 2

20

AD

Parameter 3

15

CA

Parameter 4

40

EF

Parameter 6

67

FE

Parameter 7

80

EF

Parameter 8

45

GA

Parameter 9

45

CA

Parameter 5

52

 

The ID column is the concatenation of two variables that can be combined. I would like to find in the table all the records in which the two variables are swapped among each other.

The final result needs to be

idparametercost

AC

Parameter 2

20

CA

Parameter 4

40

CA

Parameter 5

52

EF

Parameter 6

67

FE

Parameter 7

80

EF

Parameter 8

45

Thank you for your support

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @flyingfox 

 

You can try the following methods.

Column:

id2 = RIGHT('Table'[id],1)&LEFT('Table'[id],1)

vzhangti_0-1653273692106.png

Table:

New Table = UNION(VALUES('Table'[id]),VALUES('Table'[id2]))

vzhangti_1-1653273763364.png

Measure:

Count id =
CALCULATE (
    COUNT ( 'New Table'[id] ),
    FILTER ( ALL ( 'New Table' ), [id] = SELECTEDVALUE ( 'New Table'[id] ) )
)
Measure = IF([Count id]=1,0,1)

vzhangti_2-1653273821981.png

Drag Measure into the view to be displayed and set it equal to 1.

vzhangti_3-1653273882189.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

3 REPLIES 3
flyingfox
Regular Visitor

I set up the secondary key in the model. It works. Thank you

v-zhangti
Community Support
Community Support

Hi, @flyingfox 

 

You can try the following methods.

Column:

id2 = RIGHT('Table'[id],1)&LEFT('Table'[id],1)

vzhangti_0-1653273692106.png

Table:

New Table = UNION(VALUES('Table'[id]),VALUES('Table'[id2]))

vzhangti_1-1653273763364.png

Measure:

Count id =
CALCULATE (
    COUNT ( 'New Table'[id] ),
    FILTER ( ALL ( 'New Table' ), [id] = SELECTEDVALUE ( 'New Table'[id] ) )
)
Measure = IF([Count id]=1,0,1)

vzhangti_2-1653273821981.png

Drag Measure into the view to be displayed and set it equal to 1.

vzhangti_3-1653273882189.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Dear Team_Charlotte,

thank you so much for your valuable support. You undestood my issue and you almost got the result because, I am sorry, I did not mention that each record in the master Table is associated to a date. Therefore dragging your interesting Measure into the view to be displayed and setting it equal to 1, it does not produce the desidered results because the filter does not work due to the missing date in the New Table. Could you help me, please?   

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.