The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi.
Trying to sum a data field only if the sum of it is < 0 else do not sum it or return 0. IF statement or filter be best. I have over 3M records.
For example.
Acct # | Count |
999727 | 1 |
999727 | -2 |
992592 | 0 |
992035 | 1 |
992035 | -2 |
986977 | -2 |
986977 | 2 |
936300 | -1 |
Solved! Go to Solution.
Sum count 1 =
VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
CALCULATE([Sum Count],_tbl)
or
Sum count 1 =
VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
sumx(_tbl,[SUM])
Sum count 1 =
VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
CALCULATE([Sum Count],_tbl)
or
Sum count 1 =
VAR _tbl = ADDCOLUMNS(VALUES(Data[Acct #]),"SUM", [Sum Count])
RETURN
sumx(_tbl,[SUM])
CALCULATE(SUM('tabl'[Count]),'tabl'[Count]<0)
Thanks but didn't yield the answer I'm wanting. Sum only if the sum of the count is <0.