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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. 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
Super User
Super User

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!:
Power BI Cookbook Third Edition (Color)

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.