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
ChillETL
Frequent Visitor

TMDL Script to update multiple tables

Can one TMDL script update measures in more than one table. I get a syntax error when I add a second 

ref table
1 ACCEPTED SOLUTION

The above worked once I updated Power BI Desktop to the latest build.    Here is the full script:

createOrReplace

	ref table Sales

		measure 'Sales Amount by Due Date' = CALCULATE(SUM(Sales[Sales Amount]), USERELATIONSHIP(Sales[DueDateKey],'Date'[DateKey])) * 3
			formatString: \$#,0.###############;(\$#,0.###############);\$#,0.###############
			
	ref table 'Sales Order'

		measure test2 = CALCULATE(Sales[Sales Amount by Due Date],Sales[Sales Amount]>0) *2
			
			annotation PBI_FormatHint = {"isGeneralNumber":true}

View solution in original post

5 REPLIES 5
ChillETL
Frequent Visitor

An  example would be appreciated as clearly I am not getting this to work otherwise I would not have posted the question.  I am looking for an example of updating 2 or more measures in different tables in one script.  I've tried different variations of the following and I get a syntax error and apply error.

createOrReplace

    ref table Sales

        measure 'Sales Amount by Due Date' = CALCULATE(SUM(Sales[Sales Amount]), USERELATIONSHIP(Sales[DueDateKey],'Date'[DateKey]))
            formatString: \$#,0.###############;(\$#,0.###############);\$#,0.###############
            lineageTag: c2fe3283-9d89-4bee-b219-09de50cc38c5

    ref table 'Sales Order'

        measure Measure = CALCULATE(Sales[Sales Amount by Due Date],Sales[Sales Amount]>0)
            lineageTag: fd142fd3-7e80-4ac8-bd70-f0198948e754

            annotation PBI_FormatHint = {"isGeneralNumber":true}


The above worked once I updated Power BI Desktop to the latest build.    Here is the full script:

createOrReplace

	ref table Sales

		measure 'Sales Amount by Due Date' = CALCULATE(SUM(Sales[Sales Amount]), USERELATIONSHIP(Sales[DueDateKey],'Date'[DateKey])) * 3
			formatString: \$#,0.###############;(\$#,0.###############);\$#,0.###############
			
	ref table 'Sales Order'

		measure test2 = CALCULATE(Sales[Sales Amount by Due Date],Sales[Sales Amount]>0) *2
			
			annotation PBI_FormatHint = {"isGeneralNumber":true}

Hi @ChillETL ,

We really appreciate your efforts and for letting us know the update on the issue.
Please mark your reply as the solution so as to help other community members who may face similar issue in the future.

Please continue using fabric community forum for your further assistance.

Thank you

just worked for me, changed measure values from 1 and 2

 

Deku_0-1743111365760.png

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Deku
Super User
Super User

Yes


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

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.