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!View all the Fabric Data Days sessions on demand. View schedule
These give different answers in my model and I do not understand why. Can someone explain to me the difference? does it have to do with the context transition of Calculate? I have a very simple model in which sales is connected to date as a many to one relationship. Below CODE #2 gives the right answer and CODE #1 gives the wrong answer.
CODE # 1
Solved! Go to Solution.
Hi @CL7777 ,
I have made a sample for your reference, the result should be the same using the two formulas. Please not we should use >= and <= instead of > , < .
deliverydays =
CALCULATE (
COUNTROWS ( 'Date' ),
FILTER (
ALL ( 'Date' ),
'Date'[Date] >= Sales[Order Date]
&& 'Date'[Date] <= Sales[Delivery Date]
&& 'Date'[Working Day] = "WorkDay"
)
)
DeliveryDays_ =
VAR OrderDate = Sales[Order Date]
VAR DeliveryDate = Sales[Delivery Date]
VAR WorkingDays =
FILTER (
ALL ( 'Date' ),
'Date'[Date] >= OrderDate
&& 'Date'[Date] <= DeliveryDate
&& 'Date'[Working Day] = "WorkDay"
)
VAR CountWorkingDays =
COUNTROWS ( WorkingDays )
RETURN
CountWorkingDays
Also attached the pbix .
Hi @CL7777 ,
I have made a sample for your reference, the result should be the same using the two formulas. Please not we should use >= and <= instead of > , < .
deliverydays =
CALCULATE (
COUNTROWS ( 'Date' ),
FILTER (
ALL ( 'Date' ),
'Date'[Date] >= Sales[Order Date]
&& 'Date'[Date] <= Sales[Delivery Date]
&& 'Date'[Working Day] = "WorkDay"
)
)
DeliveryDays_ =
VAR OrderDate = Sales[Order Date]
VAR DeliveryDate = Sales[Delivery Date]
VAR WorkingDays =
FILTER (
ALL ( 'Date' ),
'Date'[Date] >= OrderDate
&& 'Date'[Date] <= DeliveryDate
&& 'Date'[Working Day] = "WorkDay"
)
VAR CountWorkingDays =
COUNTROWS ( WorkingDays )
RETURN
CountWorkingDays
Also attached the pbix .
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!