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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Remove Returned Widgets from Table

I have a table that shows widgets sold on a specific date and to a specific customer. Currently, my table shows a "1" in the units sold column to indicate a sale and a "-1" to indicate a return. I am looking for a way (preferably in Power Query, but DAX would work as well) to remove BOTH rows of the widget ID when it is returned (i.e. the sale and the return). I would also want my table to show if that specific widget ID was sold again at a later time (this means there could be 3 rows with the same widget ID). My goal is to transform my Current table to the Expected table listed below. 

 

Note: 

  1. When a widget is returned, I believe the sales date is ALWAYS the same date as the original purchase date (even if it was returned a day/week/month later).
  2. A widget that was returned could be sold again on the same day.

 

As you can see in the example below, I am wanting to remove Widget ID 3 because it was returned. Also note that widget ID 5 was re-sold after being returned, so I want to keep the most recent transaction in my table.

 

Capture.PNG

2 ACCEPTED SOLUTIONS
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

I'm not good at power query. Hope @ImkeF would help.

In addition, you could try to create the calculated table with the dax expression below.

 

Table 2 =
SUMMARIZE (
    'Table',
    'Table'[Widget ID],
    'Table'[Sales Date],
    'Table'[Customer],
    "a", COUNTROWS ( VALUES ( 'Table'[Units Sold] ) ),
    "Unit_Sold", CALCULATE ( SUM ( 'Table'[Units Sold] ) )
)

And then you could drag column[a] to visual level filter and then filter the value =1.

 

Capture.PNG

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
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

ImkeF
Community Champion
Community Champion

In Power Query:

 

Group on Widget ID, Sales Date and Customer and add an aggregation that sums the Units Sold. Then filter out values that return 0 on that new column.

 

image.png

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

3 REPLIES 3
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

Have you solved your problem?

If you have solved, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly?

If you still need help, please feel free to ask.

Best  Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ImkeF
Community Champion
Community Champion

In Power Query:

 

Group on Widget ID, Sales Date and Customer and add an aggregation that sums the Units Sold. Then filter out values that return 0 on that new column.

 

image.png

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous ,

I'm not good at power query. Hope @ImkeF would help.

In addition, you could try to create the calculated table with the dax expression below.

 

Table 2 =
SUMMARIZE (
    'Table',
    'Table'[Widget ID],
    'Table'[Sales Date],
    'Table'[Customer],
    "a", COUNTROWS ( VALUES ( 'Table'[Units Sold] ) ),
    "Unit_Sold", CALCULATE ( SUM ( 'Table'[Units Sold] ) )
)

And then you could drag column[a] to visual level filter and then filter the value =1.

 

Capture.PNG

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors