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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Angela000
New Member

SQL Analysis service query

 

I would like to calculate patients retention rate, for any pathent who has visisted a practice in the first 6 months(for example:Jan, Feb, Mar, Apr, May, Jun) and returned in the next 6 months(for example:Jul, Aug, Sep, Oct, Nov, Dec), I created a new measure 'Pcount' as the below

Pcount:=
COUNTROWS(
    INTERSECT(
        CALCULATETABLE(
            DISTINCT(Appointment[pat_id]),
            Appointment[appointment_attended_count]=1,
             DATESINPERIOD('Date'[FullDate], EOMONTH(MAX('Date'[FullDate]),-1),-6,MONTH)
        ),
        CALCULATETABLE(
            DISTINCT(Appointment[pat_id]),
            Appointment[appointment_attended_count]=1,
            DATESINPERIOD('Date'[FullDate], EOMONTH(MAX('Date'[FullDate]),-7),-12,MONTH)
                                )
                            )
                       )

I depolyed it to the SQL Analysis Server successfully, and run the MDX query from SSMS, please see the image link (https://i.sstatic.net/XIqSSLJc.png), Got the error from SSMS: MdxScript(NDC_Model) (8, 2) This is not a valid DAX expression.

The cube is on SQL Analysis server version 2012 enter image description here

 

Just wondering is there any issue with the query or the server version is too low to support the SET operations (INTERSECT, Exception)? I know we can't declare variables(VAR) in version 2012.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Angela000 ,

SQL Analysis server 2012 is already a very old version, and INTERSECT, EXCEPT and other functions belong to the advanced functions in DAX, may be the version really can not support all or part of the functions in the function.
Also, the error reported here already provides error localization, could you please check what function is used at that location? Or what syntax error exists in that location?

vjunyantmsft_0-1716863422556.png

If you can, please change to a more advanced version of SSAS for testing, and have checked if the error is caused by the outdated version.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Angela000 ,

SQL Analysis server 2012 is already a very old version, and INTERSECT, EXCEPT and other functions belong to the advanced functions in DAX, may be the version really can not support all or part of the functions in the function.
Also, the error reported here already provides error localization, could you please check what function is used at that location? Or what syntax error exists in that location?

vjunyantmsft_0-1716863422556.png

If you can, please change to a more advanced version of SSAS for testing, and have checked if the error is caused by the outdated version.

Best Regards,
Dino Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.