Forum Discussion

Martin0011's avatar
Martin0011
Frequent Visitor
2 years ago
Solved

Identify duplicate supplier using measure

Se the 2 tables I have with a relation with Vendor ID

Vendor TAX
Vendor IDAvailable For use Vendor IDTax
1Yes 1A
2Yes 2B
3No 3C
4No 4A
5Yes 5B
6No 6D

 

I need to acheive the below table : 

 

Vendor IDFrom Table Vendor
DuplicateYes/No - If the tax of the Vendor ID is duplicate with another Vendor ID
Duplicate GroupAssign a unique ID for the group of duplicate
Duplicate ListList all the Vendor ID assigned in the same group 

 

The challenge I have is that if I do it in Power Query or in the Table with New Colmun, the result will not be dynamic.

 

See the Avaialble for Use as a FIlter. 

If the end user select only the Available For Use to Yes, the system must calculte the field Duplicate, Duplicate Group & Dupicate List only with the Vendor filtered to Yes. 

 

I therefore need to create some calculated table, or summarize inside a measure to make sure it would work on a dinamic way. 

Any idea how to acheive this ? 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Martin0011

     

    You can create several measures as follow.

     

    Duplicate = IF(CALCULATE(COUNT('TAX'[Tax]),'TAX'[Tax] = MAX('TAX'[Tax]), ALL('Vendor'[Vendor ID])) > 1, "Y", "N")

     

     

     

    Duplicate List = IF([Duplicate] = "Y", CONCATENATEX(FILTER(ALLSELECTED('TAX'), 'TAX'[Tax] = MAX('TAX'[Tax])), 'TAX'[Vendor ID], ","))

     

     

     

    Duplicate Group = 
    IF (
        [Duplicate] = "Y",
        RANKX (
            FILTER (
                ADDCOLUMNS (
                    ALLSELECTED ( 'Vendor'[Vendor ID] ),
                    "@Duolicate", [Duplicate],
                    "@DuplicateList", [Duplicate List]
                ),
                [@Duolicate] = "Y"
            ),
            [Duplicate List],
            ,
            ASC,
            DENSE
        ),
        "-"
    )

     

     

     

    Is this the result you expect?

     

    Best Regards,
    Community Support Team _Yuliax

     

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

5 Replies

  • So I had to break down your problem in 3 measures :

     

    Duplicate = 
    VAR currentVendorID = SELECTEDVALUE('Vendor'[Vendor ID])
    VAR currentTax = LOOKUPVALUE('TAX'[Tax], 'TAX'[Vendor ID], currentVendorID)
    RETURN IF(
        CALCULATE(
            COUNTROWS('Vendor'),
            FILTER(
                ALL('Vendor'),
                'Vendor'[Vendor ID] <> currentVendorID &&
                'Vendor'[Available For Use] = "Yes" &&
                LOOKUPVALUE('TAX'[Tax], 'TAX'[Vendor ID], 'Vendor'[Vendor ID]) = currentTax
            )
        ) > 0, "Yes", "No"
    )

     

    Duplicate Group = 
    VAR currentTax = LOOKUPVALUE('TAX'[Tax], 'TAX'[Vendor ID], SELECTEDVALUE('Vendor'[Vendor ID]))
    RETURN RANKX(
        ALL('TAX'), 
        currentTax, 
        , ASC, Dense
    )

     

     

    This is the output : 

     

     

     

     

    • Martin0011's avatar
      Martin0011
      Frequent Visitor

      I think you missed the 3rd measure. In your approach, they all have the same duplicate group and the duplicate list is only the same as the vendor id. 


      The output result should be : 

      If the Filter Available for use is ALL 
          
      Vendor IDDuplicateDuplicate GroupDuplicate List
      1Y11,4
      2Y22,5
      3N- 
      4Y11,4
      5Y22,5
      6N- 
          
          
      If the Filter Available for use is YTE 
          
      Vendor IDDuplicateDuplicate GroupDuplicate List
      1N- 
      2Y12,5
      5Y12,5
      • AmiraBedh's avatar
        AmiraBedh
        Super User

        Can you please provide a clear input and output ?

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Martin0011

     

    You can create several measures as follow.

     

    Duplicate = IF(CALCULATE(COUNT('TAX'[Tax]),'TAX'[Tax] = MAX('TAX'[Tax]), ALL('Vendor'[Vendor ID])) > 1, "Y", "N")

     

     

     

    Duplicate List = IF([Duplicate] = "Y", CONCATENATEX(FILTER(ALLSELECTED('TAX'), 'TAX'[Tax] = MAX('TAX'[Tax])), 'TAX'[Vendor ID], ","))

     

     

     

    Duplicate Group = 
    IF (
        [Duplicate] = "Y",
        RANKX (
            FILTER (
                ADDCOLUMNS (
                    ALLSELECTED ( 'Vendor'[Vendor ID] ),
                    "@Duolicate", [Duplicate],
                    "@DuplicateList", [Duplicate List]
                ),
                [@Duolicate] = "Y"
            ),
            [Duplicate List],
            ,
            ASC,
            DENSE
        ),
        "-"
    )

     

     

     

    Is this the result you expect?

     

    Best Regards,
    Community Support Team _Yuliax

     

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