Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I have written a dax measure that does boolean filters on calculate but brings backs the incorrect value, it uses keepfilters when I add another column the each row shows the correct value, but the total figure is incorrect
CALCULATE(
SUM(Profit),
KEEPFILTERS(Sales[Order Date] >= start_date),
KEEPFILTERS(Sales[Order Date] <= end_date
)
please note, start_date and end_date above are variables but irrelevant for my question.
Solved! Go to Solution.
Hi @akhaliq7 ,
Please try:
1. Explicitly Handle Totals:
Measure =
// This is the total you want to get. Please modify the TotalProfit code as needed.
VAR TotalProfit = CALCULATE(SUM(Profit), ALLSELECTED(Sales))
RETURN
IF(
HASONEVALUE(Sales[Order Date]),
CALCULATE(
SUM(Profit),
KEEPFILTERS(Sales[Order Date] >= start_date),
KEEPFILTERS(Sales[Order Date] <= end_date)
),
TotalProfit
)
2. Or try completes context in the code:
MEASURE =
SUMX (
VALUES ( 'Table'[GroupField] ),
CALCULATE (
SUM ( Sales[Profit] ),
KEEPFILTERS ( Sales[Order Date] >= start_date ),
KEEPFILTERS ( Sales[Order Date] <= end_date )
)
)
Why Power BI totals might seem inaccurate - SQLBI
Obtaining accurate totals in DAX - SQLBI
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group
Hi @akhaliq7 ,
Please try:
1. Explicitly Handle Totals:
Measure =
// This is the total you want to get. Please modify the TotalProfit code as needed.
VAR TotalProfit = CALCULATE(SUM(Profit), ALLSELECTED(Sales))
RETURN
IF(
HASONEVALUE(Sales[Order Date]),
CALCULATE(
SUM(Profit),
KEEPFILTERS(Sales[Order Date] >= start_date),
KEEPFILTERS(Sales[Order Date] <= end_date)
),
TotalProfit
)
2. Or try completes context in the code:
MEASURE =
SUMX (
VALUES ( 'Table'[GroupField] ),
CALCULATE (
SUM ( Sales[Profit] ),
KEEPFILTERS ( Sales[Order Date] >= start_date ),
KEEPFILTERS ( Sales[Order Date] <= end_date )
)
)
Why Power BI totals might seem inaccurate - SQLBI
Obtaining accurate totals in DAX - SQLBI
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum -- China Power BI User Group