COUNTIF & SUMIF in DAX

0929041

New Member
Joined
Mar 23, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Dear readers,

I am facing a problem in my Excel data model. I would like to include the formulas COUNTIF & SUMIF in my data model which has to be written in DAX.

The goal I want to achieve is to sum up the quantities per ref. nr. in the data model, and to count the amount of the same ref. numbers.

Note: This is a replicated version of the real dataset and is for ease made in Excel.

1616491498304.png
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
DAX SUM IF:=
VAR Ref = Table1[Ref. nr.]
RETURN CALCULATE(SUM(Table1[Quantity]);FILTER(Table1;Table1[Ref. nr.]=Ref))

DAX COUNT IF:=
VAR Ref= Table1[Ref. nr.]
RETURN CALCULATE(COUNTROWS(Table1);FILTER(Table1;Table1[Ref. nr.]=Ref))
 
Upvote 0
Measures:

SumIf:=CALCULATE(SUM(Table1[Quantity]);FILTER(Table1;Table1[Ref. nr.]=Table1[Ref. nr.]))

CountIf:=CALCULATE(COUNTROWS(Table1);FILTER(Table1;Table1[Ref. nr.]=Table1[Ref. nr.]))
 
Upvote 0
Solution

Forum statistics

Threads
1,223,723
Messages
6,174,113
Members
452,544
Latest member
aush

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top