Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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:
Thank you for your help
Solved! Go to Solution.
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.
It works. thank you so much
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.
User | Count |
---|---|
85 | |
77 | |
68 | |
49 | |
41 |
User | Count |
---|---|
111 | |
56 | |
50 | |
42 | |
40 |