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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
diogobraga2
Helper IV
Helper IV

Data vs Model Tab Calculation Differences

I still figuring it out the difference between calculation in the Data vs Model tab, any insights are appreciated. 

 

I am considering switching a calculation from Data to Model, so I copied and pasted the working formula from Data tab to the Model tab. I am getting the following error message 'Token RightParen expected'

 

Here is the working formula from the 'Data' tab:

 

apptime_adj = if([academid_year]="2016-2017",DATEADD(application_view[apptime],1095,DAY),if([academid_year]="2017-2018",DATEADD(application_view[apptime],730,DAY),if([academid_year]="2018-2019",DATEADD(application_view[apptime],365,DAY),[apptime])))
1 ACCEPTED SOLUTION

Hi @diogobraga2 ,

 

The if else statements are also written differently in the M Language. Try this:

 

= if [academid_year]="2016-2017" then Date.AddDays([apptime],1095) else if [academid_year]="2017-2018" then Date.AddDays([apptime],730) else if [academid_year]="2018-2019" then Date.AddDays([apptime],365) else [apptime]

View solution in original post

9 REPLIES 9
Nathaniel_C
Super User
Super User

Think it is at the end as you have three ifs and a Dateadd





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




I triple checked, and I can't find a missing paren. I copied and pasted again from Data tab and I am certain it's exactly the same calculation...but on Model tab is giving me this error!

 

2019-10-10_1526.png

You are trying to copy your DAX expression in M Language.

 

DATEADD (DAX) is achieved by Date.AddDays in M Language. Refer the following for M Language:

https://docs.microsoft.com/en-us/powerquery-m/date-adddays

Thanks! I fixed the syntax, but still getting the same error. What else do you suggest? 

 

2019-10-10_1536.png

Hi @diogobraga2 ,

 

The if else statements are also written differently in the M Language. Try this:

 

= if [academid_year]="2016-2017" then Date.AddDays([apptime],1095) else if [academid_year]="2017-2018" then Date.AddDays([apptime],730) else if [academid_year]="2018-2019" then Date.AddDays([apptime],365) else [apptime]

This script worked. Thanks!

 

if [academid_year]="2016-2017" then Date.AddDays(application_view[apptime],1095) 
else if [academid_year]="2017-2018" then Date.AddDays(application_view[apptime],730) 
else if [academid_year]="2018-2019" then Date.AddDays(application_view[apptime],365)
else [apptime]

Did you click on show error?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




tarunsingla
Solution Sage
Solution Sage

There shouldn't be any difference. The section does not matter (Data vs Model) when creating calculated columns/measures.

The error indicates a missing bracket ')' in the formula. Could be a copy paste issue.

Nathaniel_C
Super User
Super User

HI @diogobraga2 ,

I can't see it right off, but I would add a paren at the end. If that doesn't work, CTRL x all except the first test, then add back in piece by piece. You can copy the whole thing and paste it into a text pad or Word. Sometimes it helps to put in another medium.

 


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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