Search

Syntax Error in DAX Measure Formula Results in Loss of Code by Christopher Webb

Active

14
0
Sign in
to vote
Type: Bug
ID: 777128
Opened: 1/22/2013 1:55:23 AM
Access Restriction: Public
2
Workaround(s)
3
User(s) can reproduce this bug
When writing complex DAX measures in SSDT, whenever there's a syntax error SSDT reverts back to the last known good state of the measure. This is very frustrating because it often means that you lose a lot of code changes, which need to be re-entered, just because you made one error!
Details (expand)

Product Language

English

Version

SQL Server 2012 SP1

Category

Analysis Services

Operating System

Windows 7 Ultimate

Operating System Language

English

Steps to Reproduce

Create an SSAS Tabular model on the Adventure Works DW database, and import the FactInternetSales table. Create a measure like so:

Sum of Sales Amount:=SUM([SalesAmount])

This works. Then edit the measure so the DAX is as follows:
Sum of Sales Amount:=SUM('[SalesAmount])

Hit enter and you'll get a dialog saying that the formula contains an invalid character. The UI will now be partially frozen (you can't change to Diagram View for example) until you correct the error, hit enter, and then move outside the cell with the formula in.

Now, re-enter the code with the syntax error in. After closing the dialog, click somewhere else in the measure grid, close the dialog again, click another cell in the measure grid again and then click back into the cell with the formula in, and you'll see the code has reverted back to the original, working expression.

This is the repro I've come up with, but it seems like I lose my changes a lot more easily than this, and that the UI doesn't always come out of its 'frozen' state.

Actual Results

As above

Expected Results

I never, ever want to lose code I've written, even if it has got a syntax error in it!

Platform

X64

Virtualization

 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Darren Gosbell on 1/22/2013 at 2:14 PM
I have a simpler repro.

1. In an Adventure Works database in FactResellerSales create a new measure with the following valid expression

Test Measure:=blank()

2. Hit enter so that SSDT will validate the expression

3. Now change it to the following (note there is a missing end bracket at the end of the expression)

Test Measure:=calculate(sum([SalesAmount]),FILTER(FactResellerSales,FactResellerSales[TaxAmt] = 0)

4. Hit the Enter key

This results in the following error

MdxScript(Model) (6, 134) The syntax for ';' is incorrect.

When you click "OK" the calculated measure reverts back to the expression from step 1. wiping out all your work and not giving you a chance to fix the syntax error.

What I expect is for the incorrect expression to be retained with a warning triangle so that I have an opportunity to correct the syntax error.
Posted by Microsoft on 1/22/2013 at 10:23 AM
Hi Chris,

Thanks for filling this issue, we will investigate this.

Thanks,
Kasper
Sign in to post a workaround.
Posted by MarkVSQL on 1/30/2013 at 8:57 AM
I write my DAX in Notepad++ and then paste it in. I don't get Intellisense, but it helps a lot with matching parens and indenting for readability, etc.
Posted by Darren Gosbell on 1/22/2013 at 2:17 PM
I now resort to doing Ctrl-A then Ctrl-C to copy complex expressions to the clipboard before I hit the enter key to submit them so that I don't loose the whole expression if there is a syntax error. It's not ideal, but it saves me a lot of re-typing