Forum Discussion

Saxon10's avatar
Saxon10
Post Prodigy
4 years ago
Solved

Unique count based on the multiple column with DAX

Hi,

 

1.If same item has mutiple time return with same code then return 1 in first line item only and remaining line items return as a 0.

Example

item 198 3000 A1, 198 4000 A1, 147 6000 A2

2.If same item does not have a mutiple time return with same code then return 1.
I am looking for New calculated column option (DAX)

 

Example

123 3000 A1, 124 4000 A1

3.If code column equal to "Not Pair" then retun 1.

Example

127 7000 Not Pair, 128 8000 Not Pair, 137 7000 Not Pair


In Excel I applying the following formula =IF(A3="Not Pair",1,IF(MATCH(B3,B:B,0)=ROW(),1,0)).
The formula logic is - if its matches 1st time it will give 1 else 0.

https://www.dropbox.com/s/jherglz8y3zzfvz/Match%20and%20Rows-SOF-25-09-2021.pbix?dl=0


Data

 

CodeItemDesired Result (Unique Count)
A1123 3000 A11
A1124 4000 A11
A2125 5000 A21
A2126 6000 A21
Not Pair127 7000 Not Pair1
Not Pair128 8000 Not Pair1
A1135 3000 A11
A2135 6000 A21
A2136 5000 A21
A2136 6000 A21
A1137 3000 A11
Not Pair137 7000 Not Pair1
Not Pair137 8000 Not Pair1
A1138 4000 A11
Not Pair138 7000 Not Pair1
Not Pair138 8000 Not Pair1
A1139 3000 A11
Not Pair139 7000 Not Pair1
A1140 4000 A11
Not Pair140 7000 Not Pair1
A2141 5000 A21
Not Pair141 7000 Not Pair1
Not Pair141 8000 Not Pair1
A2142 6000 A21
Not Pair142 7000 Not Pair1
Not Pair142 8000 Not Pair1
A1143 4000 A11
A2143 6000 A21
Not Pair143 7000 Not Pair1
A1144 3000 A11
A1144 4000 A11
Not Pair144 7000 Not Pair1
A1145 3000 A11
A1145 4000 A11
A2145 5000 A21
A2145 6000 A21
A2147 6000 A21
A2147 6000 A20
A1148 3000 A11
A1148 3000 A10
A1149 4000 A11
A1149 4000 A10
A1150 3000 A11
A2150 5000 A21
A1151 4000 A11
A2151 6000 A21
A1152 3000 A11
Not Pair152 7000 Not Pair1
A2152 5000 A21
A1153 3000 A11
A1153 4000 A11
A2153 5000 A21
A21999 5000 A21
A21999 6000 A21
A11999 3000 A11
A1155 4000 A11
A2155 6000 A21
A2156 5000 A21
A1156 4000 A11
Not Pair157 7000 Not Pair1
Not Pair157 8000 Not Pair1
A1154 3000 A11
A2154 5000 A21
A1154 4000 A11
A2155 5000 A21
A1155 4000 A10
Not Pair155 7000 Not Pair1
A2156 5000 A20
A1156 4000 A10
Not Pair156 7000 Not Pair1
Not Pair156 8000 Not Pair1
A1198 3000 A11
A1198 3000 A10
A1198 3000 A10
A1198 3000 A10
A1198 3000 A10
A1200 4000 A11
A1200 4000 A10
A1200 4000 A10
A1200 4000 A10
A1200 4000 A10
A1200 4000 A10
A1198 4000 A11
A1198 4000 A10
A1198 4000 A10
A1198 4000 A10
A1198 4000 A10
  • Saxon10 

    you need to create an index column in PQ, then use DAX to create a column

    Column = if('Table'[Code]="Not Pair",1,if('Table'[Index]=CALCULATE(min('Table'[Index]),ALLEXCEPT('Table','Table'[Item])),1,0))

    pls see the attachment below

3 Replies

  • Saxon10 

    you need to create an index column in PQ, then use DAX to create a column

    Column = if('Table'[Code]="Not Pair",1,if('Table'[Index]=CALCULATE(min('Table'[Index]),ALLEXCEPT('Table','Table'[Item])),1,0))

    pls see the attachment below