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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.