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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors