Identifying Duplicates DAX forumla not working as intended

slow1911s

New Member
Joined
May 12, 2012
Messages
6
This is the formula I'm using in a calculated column:

=IF(
CALCULATE(COUNTROWS(Table1),
FILTER(Table1,
Table1[Column1]=EARLIER(Table1[Column1]) &&
Table1[Column2]=EARLIER(Table1[Column2])
)
)>1,0,1
)

[TABLE="width: 300"]
<tbody>[TR]
[TD]Column1
[/TD]
[TD]Column2
[/TD]
[TD]CalculatedColumn
[/TD]
[/TR]
[TR]
[TD="align: center"]Billy
[/TD]
[TD="align: center"]Yes
[/TD]
[TD="align: center"]1
[/TD]
[/TR]
[TR]
[TD="align: center"]Billy
[/TD]
[TD="align: center"]Yes
[/TD]
[TD="align: center"]1
[/TD]
[/TR]
[TR]
[TD="align: center"]Billy
[/TD]
[TD="align: center"]Yes
[/TD]
[TD="align: center"]1
[/TD]
[/TR]
[TR]
[TD="align: center"]Billy
[/TD]
[TD="align: center"]Yes
[/TD]
[TD="align: center"]1
[/TD]
[/TR]
</tbody>[/TABLE]

This isn't what expect. I expect that this would put a 0 in cells 2-4 in the calculated column. If I was using basic Excel formulas it would look like this: =IF(SUMPRODUCT($A2:A2=A2)*($B2:B2=B2))>1,0,1)

I also tried EARLIEST to see if that changed things - no. I'm just trying to find unique instances of various combinations of data.

Thanks in advance.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hi!

You might want to take a look at defining a unique ID per row otherwise there's no other way that Powerpivot can tell under what context what row comes first. It'll throw you something like the count of total times that the combination appears with something like this:
Code:
=COUNTAX( FILTER( Table, 
            EARLIER([Column1])=[Column1] && 
              [Column2] =EARLIER([Column2])
                                        ),
                         [Column1]
                       )

Which in this case is 4. In regular Excel the A1 reference style is extremely useful but in Powerpivot that A1 cell reference is gone and now we need to talk to the Engine using DAX, which is a language that works with Tables only.

Hope this helps
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top