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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

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
v-stephen-msft
Community Support
Community Support

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

v-stephen-msft
Community Support
Community Support

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
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Solution Authors