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
GuillaumeL06
Regular Visitor

Counting the number of reference occurences in a list depending a quantity

Hello everyone,

 

I have a column of article references called « Article » and a quantity (column called « Qty ») which counts for each article reference how many article I need. The column « site » refers to the location where the article has to be delivered.

My request is :

I would like to have a column (called "total QTY") with a DAX expression which counts the occurrence number of article depending its quantity. It will be the total quantity for each article reference. For example, for the article «1 », I would like to have a total quantity equals to 7, for article « 2 », I would like to have a total qty equals to 1 etc.

 

Article                  Site                       QTY                      Total QTY

1                           SQY                      5                           7

1                           SAESB                  2                           7

2                           CTC                      1                           1

3                           SQY                      1                           8

3                           SAESB                  5                           8

3                           SAESA                  2                           8

8                           SQY                      1                           2

8                           SAESA                  1                           2

 

 

Thanks for your answers

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@GuillaumeL06 try this measure

 

Total Qty = CALCULATE( SUM(Table[Qty] ), ALLEXCEPT( Table, Table[Article]))


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
ntaylo06
Resolver II
Resolver II

This probably isn't best practice and probably adds redundant process time, but I have solved similar issues by:

1. Creating a new query based off of the same data source,

2. Removing all columns except what you want to count

3. Adding a calculated column that counts total

4. Creating a relationship with the full query and adding the calculated column to your visual

It makes the column slicerproof and able to be displayed right next to the "sliced" data.

parry2k
Super User
Super User

@GuillaumeL06 try this measure

 

Total Qty = CALCULATE( SUM(Table[Qty] ), ALLEXCEPT( Table, Table[Article]))


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.