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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
jersey417
Helper I
Helper I

Direct Query - Running Sum/Total

All,

 

I previously had a running sum query that worked perfectly. However, I migrated my data to a DirectQuery and it's not longer working due to the limited DAX functionality.

 

 

Initial Query before migrating to direct query.

 

Running Total =
IF (
    Report_Monthly[Date] <= TODAY (),
    CALCULATE (
        SUM ( Report_Monthly[Produced_Qty] ),
        ALLEXCEPT ( Report_Monthly, Report_Monthly[Work_Center] ),
        Report_Monthly[Date] <= EARLIER ( Report_Monthly[Date] )
    )
)

 

 

When I tired to use this same DAX function when switching over to a DirectQuery the following error displays. Capture.PNG 

 

 

Based on other posts I assumed the following would have worked.

 

Running Total =
IF (
    Report_Monthly[Date] <= TODAY (),
CALCULATE (
    SUM ( Report_Monthly[Produced_Qty] ),
    FILTER (
        ALLEXCEPT ( Report_Monthly, Report_Monthly[Work_Center]),
        Report_Monthly[Date] <= MAX ( Report_Monthly[Date] ))
    )
)

 

However, I'm getting the following error "Function 'Calculate' is not allowed as part of calculated column DAX expression in DirectQuery models." I've  gone into options and selected "Allow unrestricted measures in DriectQuery mode."

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @jersey417,

From your formula, you created a calculated column rather than a measure. In the case you posted, they create a measure rather than a calculated column. You get the error caused by DAX Formula Compatibility limitation, please review more details in the blog: DAX Formula Compatibility in DirectQuery Mode

Please create a measure using the formula below and check if it works fine.

Running Total =
IF (
    FIRSTNONBLANK ( Report_Monthly[Date], Report_Monthly[Date] ) <= TODAY (),
    CALCULATE (
        SUM ( Report_Monthly[Produced_Qty] ),
        FILTER (
            ALLEXCEPT ( Report_Monthly, Report_Monthly[Work_Center] ),
            Report_Monthly[Date] <= MAX ( Report_Monthly[Date] )
        )
    )
)


Best Regards,
Angelia


View solution in original post

1 REPLY 1
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @jersey417,

From your formula, you created a calculated column rather than a measure. In the case you posted, they create a measure rather than a calculated column. You get the error caused by DAX Formula Compatibility limitation, please review more details in the blog: DAX Formula Compatibility in DirectQuery Mode

Please create a measure using the formula below and check if it works fine.

Running Total =
IF (
    FIRSTNONBLANK ( Report_Monthly[Date], Report_Monthly[Date] ) <= TODAY (),
    CALCULATE (
        SUM ( Report_Monthly[Produced_Qty] ),
        FILTER (
            ALLEXCEPT ( Report_Monthly, Report_Monthly[Work_Center] ),
            Report_Monthly[Date] <= MAX ( Report_Monthly[Date] )
        )
    )
)


Best Regards,
Angelia


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.