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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
IoannisT
Frequent Visitor

Unconventional remove duplicate but keep data from another column

Greetings to all the Fabric community!

 

I have the following issue.

Our business database is generating reports without considering "unique key" values, meaning that for some entries, if unique key is the same but different people are involved, it creates 2 rows. The problem becomes more evident on the screenshot below.

IoannisT_0-1714728192742.png

For example, Receipt= a1, two people were the "referral" of this sale, if I populate the data on PowerBI, it appears falsely that this department on that day sold 2x mice of 2* $10 each. 

 

What I would like to see is more aligned with "Solution3" on the screenshot above.

 

I have tried, remove duplicates, grouping, creating new data model but none of this has worked.

 

I am creating various visuals like:

*total sales per department per day filter but also a generic head counter on the "Employee_Name".
I understand that ideally there should be a DAX function to equally devide the price per item per referal but this is something we are not exploring at the time.

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @IoannisT 

Based on your description, you can refer to the following solution.

Sample data 

vxinruzhumsft_0-1714974359402.png

You can create a new table first.

New Table =
SUMMARIZE (
    'Table',
    [Receipt_ID],
    'Table'[item_ID],
    'Table'[Quantity],
    'Table'[price],
    'Table'[Department],
    "Name", CONCATENATEX ( 'Table', [Ref.Employee_Name], "," )
)

vxinruzhumsft_1-1714974914275.png

2.Create a employee_name table

Employee_Name = SUMMARIZE('Table',[Receipt_ID],'Table'[Ref.Employee_Name])

vxinruzhumsft_2-1714974928061.png

There are no relationships among the tables.

3.Then create a measure

Sum_price =
VAR a =
    COUNTROWS (
        FILTER (
            Employee_Name,
            CONTAINSSTRING ( MAX ( 'New Table'[Name] ), Employee_Name[Ref.Employee_Name] )
        )
    )
RETURN
    CALCULATE (
        SUM ( 'New Table'[price] ),
        FILTER (
            'New Table',
            a > 0
                && 'New Table'[Receipt_ID] IN VALUES ( Employee_Name[Receipt_ID] )
        )
    )
Total_price =
VAR a =
    ADDCOLUMNS ( 'New Table', "sumprice", [Sum_price] )
RETURN
    SUMX (
        FILTER ( a, [Receipt_ID] IN VALUES ( 'New Table'[Receipt_ID] ) ),
        [sumprice]
    )

Then put the following code to the table visual

vxinruzhumsft_3-1714974985479.png

 

And put the employee name of employee table to a slicer.

Output

vxinruzhumsft_4-1714975026978.png

Best Regards!

Yolo Zhu

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

 

 

 

 

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @IoannisT 

Based on your description, you can refer to the following solution.

Sample data 

vxinruzhumsft_0-1714974359402.png

You can create a new table first.

New Table =
SUMMARIZE (
    'Table',
    [Receipt_ID],
    'Table'[item_ID],
    'Table'[Quantity],
    'Table'[price],
    'Table'[Department],
    "Name", CONCATENATEX ( 'Table', [Ref.Employee_Name], "," )
)

vxinruzhumsft_1-1714974914275.png

2.Create a employee_name table

Employee_Name = SUMMARIZE('Table',[Receipt_ID],'Table'[Ref.Employee_Name])

vxinruzhumsft_2-1714974928061.png

There are no relationships among the tables.

3.Then create a measure

Sum_price =
VAR a =
    COUNTROWS (
        FILTER (
            Employee_Name,
            CONTAINSSTRING ( MAX ( 'New Table'[Name] ), Employee_Name[Ref.Employee_Name] )
        )
    )
RETURN
    CALCULATE (
        SUM ( 'New Table'[price] ),
        FILTER (
            'New Table',
            a > 0
                && 'New Table'[Receipt_ID] IN VALUES ( Employee_Name[Receipt_ID] )
        )
    )
Total_price =
VAR a =
    ADDCOLUMNS ( 'New Table', "sumprice", [Sum_price] )
RETURN
    SUMX (
        FILTER ( a, [Receipt_ID] IN VALUES ( 'New Table'[Receipt_ID] ) ),
        [sumprice]
    )

Then put the following code to the table visual

vxinruzhumsft_3-1714974985479.png

 

And put the employee name of employee table to a slicer.

Output

vxinruzhumsft_4-1714975026978.png

Best Regards!

Yolo Zhu

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

 

 

 

 

you are a star! Thanks so much!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.