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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
databot_kd
Helper II
Helper II

DAX to remove rows that are similar but comparing different columns/rows

Hi Community, 

 

hoping you can assist please.

I am trying to remove rows from my table using DAX based on what are considered as duplicate. 

For example from the screenshot below APL to GLG and GLG to APL is the same transfer i need it to only show one row. 

databot_kd_0-1704857238949.png

 

Any help would be appreciated

Group ToGroup FromTransfer Amount
APLGLG1000
GLGAPL1000
GLGPCH450
PCHGLG450
PLSKLM360
KLMPLS360
2 ACCEPTED SOLUTIONS
databot_kd
Helper II
Helper II

Hi community, 

 

hoping you can assist. I am trying to create a variance to show the balance between inter related entities. 

Please see below of my current data and my required output
I have provided any updated screenshot as this hopefully will clarify the current data output and issue. 


databot_kd_0-1705307045991.png



Thanks
@Ahmed 
@Jihwan_Kim 

View solution in original post

Hi @databot_kd ,

If I understand correctly, the issue is that you want to remove rows. Please try the following methods and check if they can solve your problem:

1.Create the simple table. 

vjiewumsft_0-1705453894020.png

 

2.Create a calculated column that generate a unique identifier for each transfer.

 

Column = 
VAR GroupFrom = [FromBiz]
VAR GroupTo = [ToBiz]
VAR MinGroup = MIN(GroupFrom, GroupTo)
VAR MaxGroup = MAX(GroupFrom, GroupTo)
RETURN
CONCATENATE(MinGroup, MaxGroup)

3.Create a new table Table 2 that removes duplicates based on the column.

Table 2 = 
SUMMARIZE(
    'Table',
    'Table'[Column],
    "FromBiz", MINX(FILTER('Table', 'Table'[Column] = EARLIER('Table'[Column])), [FromBiz]),
    "ToBiz", MAXX(FILTER('Table', 'Table'[Column] = EARLIER('Table'[Column])), [ToBiz]),
    "Amount", SUMX(FILTER('Table', 'Table'[Column] = EARLIER('Table'[Column])), [Amount])
)

4.The result is shown below.

vjiewumsft_1-1705453972786.png

 

Looking forward to your reply.

Best Regards,

Wisdom Wu

 

View solution in original post

7 REPLIES 7
databot_kd
Helper II
Helper II

Hi community, 

 

hoping you can assist. I am trying to create a variance to show the balance between inter related entities. 

Please see below of my current data and my required output
I have provided any updated screenshot as this hopefully will clarify the current data output and issue. 


databot_kd_0-1705307045991.png



Thanks
@Ahmed 
@Jihwan_Kim 

Hi @databot_kd ,

If I understand correctly, the issue is that you want to remove rows. Please try the following methods and check if they can solve your problem:

1.Create the simple table. 

vjiewumsft_0-1705453894020.png

 

2.Create a calculated column that generate a unique identifier for each transfer.

 

Column = 
VAR GroupFrom = [FromBiz]
VAR GroupTo = [ToBiz]
VAR MinGroup = MIN(GroupFrom, GroupTo)
VAR MaxGroup = MAX(GroupFrom, GroupTo)
RETURN
CONCATENATE(MinGroup, MaxGroup)

3.Create a new table Table 2 that removes duplicates based on the column.

Table 2 = 
SUMMARIZE(
    'Table',
    'Table'[Column],
    "FromBiz", MINX(FILTER('Table', 'Table'[Column] = EARLIER('Table'[Column])), [FromBiz]),
    "ToBiz", MAXX(FILTER('Table', 'Table'[Column] = EARLIER('Table'[Column])), [ToBiz]),
    "Amount", SUMX(FILTER('Table', 'Table'[Column] = EARLIER('Table'[Column])), [Amount])
)

4.The result is shown below.

vjiewumsft_1-1705453972786.png

 

Looking forward to your reply.

Best Regards,

Wisdom Wu

 

Thanks @v-jiewu-msft 

Your solution really helped me. Much appreciated,

Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file whether it suits your requirement.

 

Jihwan_Kim_0-1704860611257.png

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi @Jihwan_Kim , thanks for asssiting. 

Tried this had a issues when using EARLIER for the amount as the amount is a measure coming from another table. Apologies i should have mentioned that. 

amitchandak
Super User
Super User

@databot_kd , Create a measure like this use with Group To , Group From in visual

 

measure =Sumx(summarize(Table, Table[Group To],Table[Group From], Table[Transfer Amount]),Table[Transfer Amount])

Hi @amitchandak ,

Thanks for assisting. I tried the measure you provided but i get the same result as before.
Not sure if this is cause the amount is coming from a different table. Would you have any other thoughts on where i am going wrong?

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.