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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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 .
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
Check out the November 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 59 | |
| 43 | |
| 42 | |
| 23 | |
| 17 |
| User | Count |
|---|---|
| 190 | |
| 122 | |
| 96 | |
| 66 | |
| 47 |