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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mheyde
New Member

Counting/Summing values based on a fields information

Hi,

 

I am trying to COUNT and SUM values of a table based on particular conditions/values of other cells.

 

Example: 
SUM "Amount" where "OrderType"= Refund

Expected Result: -30,00

 

or

COUNT "ItemQuantity" where "OrderType"= Order and "OrderDate" 25.10.2022<26.10.2022

Expected Result: 6

 

Sample Data:

mheyde_1-1670425040506.png

 

Thank you for your help

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @mheyde ,

 

Based on your sample data and expected results, you can create two measures.

Measure = CALCULATE(SUM('Table'[Amount]),FILTER('Table',[OrderType]="Refund"))
Measure 2 = CALCULATE(SUM('Table'[ItemQuantity]),FILTER('Table',[OrderType]="Order"&&[OrderDate]>=DATE(2022,10,25)&&[OrderDate]<=DATE(2022,10,26)))

vstephenmsft_0-1670469003334.png

However, the above two formulas will dynamically change the result according to the filtering of slicers or filters, such as the following cases.

vstephenmsft_1-1670469076033.png

If you want to remove the slicer's filter, add the ALL function to it.

Measure = CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),[OrderType]="Refund"))
Measure 2 = CALCULATE(SUM('Table'[ItemQuantity]),FILTER(ALL('Table'),[OrderType]="Order"&&[OrderDate]>=DATE(2022,10,25)&&[OrderDate]<=DATE(2022,10,26)))

vstephenmsft_2-1670469143630.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
mheyde
New Member

It works. thank you so much

Anonymous
Not applicable

Hi @mheyde ,

 

Based on your sample data and expected results, you can create two measures.

Measure = CALCULATE(SUM('Table'[Amount]),FILTER('Table',[OrderType]="Refund"))
Measure 2 = CALCULATE(SUM('Table'[ItemQuantity]),FILTER('Table',[OrderType]="Order"&&[OrderDate]>=DATE(2022,10,25)&&[OrderDate]<=DATE(2022,10,26)))

vstephenmsft_0-1670469003334.png

However, the above two formulas will dynamically change the result according to the filtering of slicers or filters, such as the following cases.

vstephenmsft_1-1670469076033.png

If you want to remove the slicer's filter, add the ALL function to it.

Measure = CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),[OrderType]="Refund"))
Measure 2 = CALCULATE(SUM('Table'[ItemQuantity]),FILTER(ALL('Table'),[OrderType]="Order"&&[OrderDate]>=DATE(2022,10,25)&&[OrderDate]<=DATE(2022,10,26)))

vstephenmsft_2-1670469143630.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.