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
RAdams
Helper III
Helper III

Flag Multiple Entries on Multiple Columns

I've got some Product Data that contains Product Code, UMseq and UM. 

 

I'm only allowed to have one UM per ProductCode and UMSeq. In the example below, CRA286 and UMseq has two UM's. This is incorrect and I would like to flag this. I've been racking my head but can't figure out the best way to do this. The flag can be 1/0. Any help would be appreciated. 

 

PBIDesktop_2020-12-17_15-14-49.png

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@RAdams ,

as column - this will flag all more than one rows
flag = if(countx(filter(Table,[product] = earlier([product]) && [UMSeq] = earlier([UMSeq])),[um]) >1, True(), False())

Measure

use this with product or UMSeq or UM


False = countx(filter(summarize(Table,[product],[UMSeq], "_1", calculate(count([UMSeq]),allexcept(Table,[product],[UMSeq]))),[_1]>1),[product])

View solution in original post

Hi @RAdams 

 

Count() and Countx() count the number of cells in a column that contain non-blank values. They will count the duplicate values. It seems your data has duplicate um values per productcode and umseq, so Distinctcount() is more suitable. Please try below column codes, this should work.

flag = 
IF (
    CALCULATE (
        DISTINCTCOUNT ( Table1[um] ),
        FILTER (
            Table1,
            Table1[productcode] = EARLIER ( Table1[productcode] )
                && Table1[umseq] = EARLIER ( Table1[umseq] )
        )
    ) > 1,
    1,
    0
)

 122301.jpg

 

Please take note that DISTINCTCOUNT() will include the Blank value. If you have blank um value in your table and you want to count it as a distinct value, you could use DISTINCTCOUNT() as above. Otherwise if you don't want to count a blank value, you could use DISTINCTCOUNTNOBLANK() to replace DISTINCTCOUNT() in the codes.

 

Best Regards,
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.

View solution in original post

5 REPLIES 5
v-jingzhang
Community Support
Community Support

Hi @RAdams , has my solution solved this problem? If so, kindly accept it as the solution to help close this topic. Otherwise if you are still confused about it, please provide more details about how it is going now. Thanks a lot.


Regards,
Jing

RAdams
Helper III
Helper III

Thanks so much for all your help. I've been working on this but I'm still having issues. 

 

Here is the Column Code I'm using:

 

 Flag Count Test = 
IF(
     COUNTX(
         filter('Canopy PBI UM Setup',
         'Canopy PBI UM Setup'[productcode] = earlier('Canopy PBI UM Setup'[productcode]) && 
         'Canopy PBI UM Setup'[umseq] = earlier('Canopy PBI UM Setup'[umseq])),
         [um]) 
         > 1, 
         "TRUE", 
         "FALSE")

 

However, Im getting these results. Row 4 - 6 should be giving me a Flag of 1 but it's not:

 

PBIDesktop_2020-12-22_11-13-19.png

 

 

 

 

 

 

 

 

 

The Multi Flag Column is just the Countx Code. I wanted to see what the total was. Obviously, its not 1 or 0! 

 

Any more help would be apprecaited. Just an FYI, I was getting the same results with all the suggestions that were given. 

 

Thanks again! R

Hi @RAdams 

 

Count() and Countx() count the number of cells in a column that contain non-blank values. They will count the duplicate values. It seems your data has duplicate um values per productcode and umseq, so Distinctcount() is more suitable. Please try below column codes, this should work.

flag = 
IF (
    CALCULATE (
        DISTINCTCOUNT ( Table1[um] ),
        FILTER (
            Table1,
            Table1[productcode] = EARLIER ( Table1[productcode] )
                && Table1[umseq] = EARLIER ( Table1[umseq] )
        )
    ) > 1,
    1,
    0
)

 122301.jpg

 

Please take note that DISTINCTCOUNT() will include the Blank value. If you have blank um value in your table and you want to count it as a distinct value, you could use DISTINCTCOUNT() as above. Otherwise if you don't want to count a blank value, you could use DISTINCTCOUNTNOBLANK() to replace DISTINCTCOUNT() in the codes.

 

Best Regards,
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.

v-jingzhang
Community Support
Community Support

Hi @RAdams 

 

Amit's column and measure DAX codes should work well.

Additionally, you could also try the following measure code.

M_Flag =
IF (
    CALCULATE (
        COUNT ( 'Table'[UM] ),
        ALLEXCEPT ( 'Table', 'Table'[Product Code], 'Table'[UMseq] )
    ) > 1,
    1,
    0
)

 122202.jpg

Kindly let me know if this helps.

Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.

amitchandak
Super User
Super User

@RAdams ,

as column - this will flag all more than one rows
flag = if(countx(filter(Table,[product] = earlier([product]) && [UMSeq] = earlier([UMSeq])),[um]) >1, True(), False())

Measure

use this with product or UMSeq or UM


False = countx(filter(summarize(Table,[product],[UMSeq], "_1", calculate(count([UMSeq]),allexcept(Table,[product],[UMSeq]))),[_1]>1),[product])

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.

Top Solution Authors