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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
replayyy
Frequent Visitor

Calculate Sum of column based on a column total by client and type of product

Dear All,

 

I am trying to calculate how much revenue is gained through clients which buy a low annual quantity for specific type of products.

 

Enclosed I put 2 tables as a reference. 

 

Steps I am trying to do but doesnt work:

 

Total revenue type good= CALCULATE(SUM(Transaction Table[amount]),FILTER(Transaction Table[type] = "Revenue"), FILTER(Type clients[type] = "Good"))

Total qty sold = CALCULATE(SUM(Transaction Tabel[qty]),FILTER(Type clients[type} = "Good"))
IF(Total qty sold > 5, Total revenue type good,0) 
 
Now I would like to display the amount of revenue generated by "Good" clients while total quantity sold based on item level does not exceed 5 through the year.
 
Can anyone point me into the right direction?
 
Transaction Table
Client nameDatetypeAmountqtyItemcode
A2019Revenue10001Item 1
B2019Revenue2008Item 1
C2019Revenue3008Item 1
D2019Revenue5006Item 1
E2019Revenue8001Item 1
F2019Revenue9002Item 1
A2019Revenue5006Item 2
B2019Revenue664Item 2
C2019Revenue5002Item 2
D2019Revenue3007Item 2
E2019Revenue40010Item 2
F2019Revenue8001Item 2
A2019Revenue5006Item 2
B2019Revenue664Item 2
C2019Revenue5002Item 2
D2019Revenue-3007Item 2
E2019Revenue-400-5Item 2
F2019Revenue8001Item 2
12019Costs-50  
22019Costs-3  
32019Costs-500  
42019Costs-800  
52019Costs-9000  
62019Costs-10000  
72019Costs-5000  
82019Costs-400  

 

Type client

Client nameType
AGood
BGood
CGood
DGood
EBad
FBad
1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

Hi @replayyy ,

 

 

Try this

 

Measure = SUMX(FILTER(Revenue,RELATED('Client Category'[Type]) = "Good" && Revenue[qty] < 5),Revenue[Amount])

 

1.jpg 

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
harshnathani
Community Champion
Community Champion

Hi @replayyy ,

 

 

Try this

 

Measure = SUMX(FILTER(Revenue,RELATED('Client Category'[Type]) = "Good" && Revenue[qty] < 5),Revenue[Amount])

 

1.jpg 

 

Regards,
Harsh Nathani

Appreciate with a Kudos!! (Click the Thumbs Up Button)
Did I answer your question? Mark my post as a solution!

amitchandak
Super User
Super User

@replayyy , use all expect and build this formula at the client level and use

https://www.sqlbi.com/articles/using-allexcept-versus-all-and-values/

Thnx Amitchandak, I have read the article and I am not sure how to incorporate the allexcept function. Care to elaborate a little?

 

Thank you!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.