cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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:

1 ACCEPTED SOLUTION
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)))``

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

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)))``

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.

2 REPLIES 2
New Member

It works. thank you so much

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)))``

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

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)))``

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.

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

#### Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Top Solution Authors
Top Kudoed Authors