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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
abujouz86
Helper II
Helper II

Sum sales quantity of gift item when sales order includes a gift tag

Hello,

 

I can't figure out the solution to this challenge and how to write the dax formula. My dataset is a sales table where each row is a line of the sales order. The table includes a column for the sales order number, column for the item number, and column for the unit sales quantity.

 

We have gift items that can be sold with a gift tag, and each has an item number. When sold together they have the same sales order number - the gift item (e.g. 000954) and the gift tag (e.g. 000307) but are separate lines on the sales order. The gift tag can also be included on the sale of a different gift item (e.g. 000957). These two gift items (000954 and 000957) can also be sold with a different gift tag (e.g. 000308).

 

I would like to separately sum the quantity of sales of the gift items when the sale includes one of the gift tags, and exclude the sales quantity of the gift items when the sale does not include the gift tag.

 

Below is a sample of the data, thank you for your advice and help!

 

Order numberItemSales quantity
63970456000307          1
63970456000957          1
63970560000957          1
63970602000957          1
63970848000957          1
63970891000957          1
63971810000954          4
63971923000954          1
63971931000307          1
63972498000308          1
63972561000954          1
63972896000308          1
63972896000954          1
1 ACCEPTED SOLUTION
abujouz86
Helper II
Helper II

I created 2 new tables - one filtering the item number column excluding the gift tag items and the other table including only the gift tag items. Then I joined the tables on the sales order number and customer address. 

View solution in original post

5 REPLIES 5
abujouz86
Helper II
Helper II

I created 2 new tables - one filtering the item number column excluding the gift tag items and the other table including only the gift tag items. Then I joined the tables on the sales order number and customer address. 

amitchandak
Super User
Super User

@abujouz86 , Not very clear. Try new measures like

Gift item Sum =sumx(filter(Sales, Sales[Item] in {"000954","000307"}), Sales[Sales quantity])

Non Gift item Sum = sumx(filter(Sales, Sales[Item] not in {"000954","000307"}), Sales[Sales quantity])

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you. But this adds the gift item and the gift tag, I only want the sales quantity for the gift item if it includes the gift tag on the sales line. 

 

In other words, if the sales order number includes both the gift item and the gift tag sum only the sales quantity for the gift item.

CheenuSing
Community Champion
Community Champion

Hi @abujouz86 ,

 

Can you share the data in an excel file and load it to Google Drive or One Drive and give the link to access here.

 

Also for the sample data what is the output expected.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Thank you. The expected output should be the running total of the gift item (e.g. 000954 or 000957) if the sales order includes the gift tag (e.g. 000307 or 000308). I don't want to add the sales quantity of both the gift item and the gift tag.

 

In other words, if the sales order number includes both the gift item and the gift tag sum only the sales quantity for the gift item.

 

One drive link

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.