Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

Reply
CL7777
Helper III
Helper III

what is the difference between these two dax calculated columns

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

deliverydays=
CALCULATE (COUNTROWS ( 'Date' ),
FILTER (
ALL ( 'Date' ),
'Date'[Date] > Sales[Order Date]
&& 'Date'[Date] < Sales[Delivery Date]
&& 'Date'[Working Day] = "WorkDay" 
        )
)
 
CODE # 2
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


1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

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

 

Capture.PNG

 

Also attached the pbix .

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

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

 

Capture.PNG

 

Also attached the pbix .

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
VasTg
Memorable Member
Memorable Member

@CL7777 

 

I guess you are creating the column in Sales table and i believe its the context transition as you said which is filtering the data. Try countx instead of calculate to verify that.

Connect on LinkedIn

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors