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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
DelphiDe
New Member

MdxScriptModel error code

DelphiDe_0-1753889853194.png

Can anyone tell what I am doing wrong here, Table [Step] is a forumula I copied from somewhere else, see below 

 

Step =
VAR CurrentDay = MAX( Days[Value] )    
VAR ProjectDays = MAX( Master[Finish Date].[Date] ) - MAX( Master[Start Date].[Date] )
VAR DaysFromStartDate = MAX(Master[Start Date].[Date] ) - VALUE( [Selected Date] )
VAR DaysFromEndDate = DaysFromStartDate = ProjectDays

RETURN
IF(
    AND( CurrentDay >= DaysFromStartDate , CurrentDay <= DaysFromEndDate ),
        1,
            0 )
2 ACCEPTED SOLUTIONS
FBergamaschi
Solution Sage
Solution Sage

The bold part is a boolean, the Italic part seems to be an integer as it is a date, you cannot compare them. Which is also logical to me, why should you compare a date (CurrentDay like july 30 2025) with a number of days like 2 or 3 (DaysFromEndDate)?

 

Step =
VAR CurrentDay = MAX( Days[Value] )    
VAR ProjectDays = MAXMaster[Finish Date].[Date] ) - MAXMaster[Start Date].[Date] )
VAR DaysFromStartDate = MAX(Master[Start Date].[Date] ) - VALUE[Selected Date] )
VAR DaysFromEndDate = DaysFromStartDate = ProjectDays

 

RETURN
IF(
    ANDCurrentDay >= DaysFromStartDate , CurrentDay <= DaysFromEndDate ),
        1,
            0 )
 
If you can show us what you are trying to do and the structure of the tables we can try to fix the code
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

View solution in original post

Ritaf1983
Super User
Super User

Hi @DelphiDe 

It looks like there's likely a typo in your last variable. This line:

VAR DaysFromEndDate = DaysFromStartDate = ProjectDays

is invalid syntax – it seems you meant to perform a calculation like:

VAR DaysFromEndDate = DaysFromStartDate + ProjectDays

In the comparison step

CurrentDay <= DaysFromEndDate

you’re comparing a number to a boolean, which causes the engine to throw an error — it expects a number, not a TRUE/FALSE value. Fixing the assignment should resolve the issue.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

5 REPLIES 5
v-veshwara-msft
Community Support
Community Support

Hi @DelphiDe ,
Just wanted to check if the responses provided were helpful. If further assistance is needed, please reach out.
Thank you.

v-veshwara-msft
Community Support
Community Support

Hi @DelphiDe ,
We wanted to kindly follow up regarding your query. If you need any further assistance, please reach out.
Thank you.

v-veshwara-msft
Community Support
Community Support

Hi @DelphiDe ,
Just checking in to see if your issue is resolved.
Could you confirm if the solutions provided by @Ritaf1983 and @FBergamaschi were helpful in resolving your issue.

If further assistance is needed, please reach out.
Thank you.
Also thanks to @Ritaf1983 and @FBergamaschi for your inputs.

Ritaf1983
Super User
Super User

Hi @DelphiDe 

It looks like there's likely a typo in your last variable. This line:

VAR DaysFromEndDate = DaysFromStartDate = ProjectDays

is invalid syntax – it seems you meant to perform a calculation like:

VAR DaysFromEndDate = DaysFromStartDate + ProjectDays

In the comparison step

CurrentDay <= DaysFromEndDate

you’re comparing a number to a boolean, which causes the engine to throw an error — it expects a number, not a TRUE/FALSE value. Fixing the assignment should resolve the issue.

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
FBergamaschi
Solution Sage
Solution Sage

The bold part is a boolean, the Italic part seems to be an integer as it is a date, you cannot compare them. Which is also logical to me, why should you compare a date (CurrentDay like july 30 2025) with a number of days like 2 or 3 (DaysFromEndDate)?

 

Step =
VAR CurrentDay = MAX( Days[Value] )    
VAR ProjectDays = MAXMaster[Finish Date].[Date] ) - MAXMaster[Start Date].[Date] )
VAR DaysFromStartDate = MAX(Master[Start Date].[Date] ) - VALUE[Selected Date] )
VAR DaysFromEndDate = DaysFromStartDate = ProjectDays

 

RETURN
IF(
    ANDCurrentDay >= DaysFromStartDate , CurrentDay <= DaysFromEndDate ),
        1,
            0 )
 
If you can show us what you are trying to do and the structure of the tables we can try to fix the code
 

If this helped, please consider giving kudos and mark as a solution

@me in replies or I'll lose your thread

Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

Consider voting this Power BI idea

Francesco Bergamaschi

MBA, M.Eng, M.Econ, Professor of BI

Helpful resources

Announcements
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.