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

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

Reply
lulufly
Frequent Visitor

count and sum values filter by many columns

Hello,

 

I have the table bellow with date, order number, value and 5 columns for the 5 promotions that i can use an each order.

 

table

 

What is the best way to get total orders by promotions and the quantity orders by promotion.

 

Regard that i can have the same promotion in difierent column buy never same promotion on the same order (Row)

 

Thaks for all

 

Regards

 

Luis

 

8 REPLIES 8
Greg_Deckler
Community Champion
Community Champion

I would unpivot your promotion columns.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hu Greg,

 

I tried that, but with that i got duplicates orders values.

 

Sorry, im really bad with pivot and unpivot ;(

 

thanks  

Anonymous
Not applicable

What does it mean that an order has several promotions attached to it?

Best
D

Means that for each order we can have up to 5 promotions attached.

 

Ex:

 

Order 10, can have, 10% discount for the 1st purchase, 10% birthday month, Free shipping and 15% discount with salesman code

Order 20, can have free Shipping and 10% discont for the fisrt purchase

Order 30, can have 10% birthday discount

Order 40, can have 15% discount with salesman code

....

 

regards

 

Luis

Anonymous
Not applicable

I gather they are cumulative?

If the first discount is 10% and the second 20%, then the total discount is 30%? IS that correct?

Best
D
Anonymous
Not applicable

We need data in a text form to quickly paste it into PBI. A picture won't do in this case.

But the solution to this is either 1) unpivot the table so that the name of the promotion becomes a value in a column and then do DISTINCTCOUNT on order id or 2) create a many-to-many relationship between unique orders and unique promotions. For this you'll need a bridge table that'll link orderid and promotionid (promotion name).

Best
D
Anonymous
Not applicable

Here's a solution attached that uses the Many-To-Many technique. Please analyze this thoroughly so that you understand it. I've put a note in the report that explains why it's working the way it does. If you want to know more about Many-To-Many, then please go to www.sqlbi.com and search for articles on it by typing in the Search Box "many to many."

 

Best

D

Anonymous
Not applicable

And here's a solution that is simpler than the previous one but requires you to indicate orders with no promotions as well. But the advantage is you just have 2 measures that work IN ALL CIRCUMSTANCES.

 

Best

D

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.