cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DNA Frequent Visitor
Frequent Visitor

Dax Statement: The end of the input was reached

I am attempting to create an IF dax statement that will have about 5 conditions to it and it's comparing information between dates. I have tried entering the statement and i get the following message in the error message "The end of the input was reached" and it highlights in red the last couple of words in my statement.


What does the error "The end of the input was reached" mean? Do DAX statement have a specified length?

1 ACCEPTED SOLUTION

Accepted Solutions
Moderator v-caliao-msft
Moderator

Re: Dax Statement: The end of the input was reached

Hi @DNA,

 

Please try the DAX below.

Age Group = 
If([borrower dob] >= Date(1930,1,1) && [borrower dob] <= Date(1945,12,31),"Silent Generation",
If([borrower dob] >= Date(1946,1,1) && [borrower dob] <= Date(1964,12,31),"Baby Boomer", 
If ([borrower dob] >= Date(1965,1,1) && [borrower dob] <= Date(1981,12,31),"Gen X","Millennials")))

Capture.PNG

 

 

Regards,

Charlie Liao

6 REPLIES 6
DNA Frequent Visitor
Frequent Visitor

Re: Dax Statement: The end of the input was reached

Bumping this - I'm a new poster and i don't think this got posted until email was verified. 

Super User
Super User

Re: Dax Statement: The end of the input was reached

It most likely means you're either missing a close parenthesis or you have too many, or some other punctuation mistake. But it's hard to troubleshoot a formula if you don't post it so we can see.

DNA Frequent Visitor
Frequent Visitor

Re: Dax Statement: The end of the input was reached

This is what I'm trying to do

 

I have a column in my table called Borrower Date of Birth in date format for each row

 

I am trying to create a new column called "Age Group" and use Borrower Date of Birth to create a Dax statement to populate the fields based on my formula. I am trying to create the following age groupings:  

 

"Silent Generation" - if you are born between 1/1/1930 and 12/31/1945

"Baby Boomer" - if you are born between 1/1/1946 and 12/31/1964

"Gen X" - if you are born between 1/1/1965 and 12/31/1981

"Millennials" - if you are born after 1/1/1982

 

Below was my statement and received the message "The end of the input was reached"

 

If([borrower dob] >= Date(1930,1,1) && {borrower dob} <= Date(1945,12,31),”Silent Generation”, If({borrower dob} >= Date(1946,1,1) && {borrower dob} <= Date(1964,12,31),”Baby Boomer”. If ({borrower dob} >= Date(1965,1,1) && {borrower dob) <= Date(1981,12,31),”Gen X”, If([Borrower DOB] >= DATE(1982|1|1)|"Millennials")

Super User
Super User

Re: Dax Statement: The end of the input was reached

You have all kinds of syntax mistakes in there. You're using {curly brackets} where you should be using [square brackets], you have open {curly brackets without a close at the end, open {curly brackets closed by a square bracket], you have a period in place of a comma, you're using paired quotation marks instead of neutral, you're using pipe characters | instead of commas, and you're missing two close parentheses )) at the end. On top of all that, your last IF statement only has 2 arguments when it requires 3.

 

You need to space out and format your code so it's easier for you to find mistakes.

 

IF(
	[Borrower DOB] >= Date(1930, 1, 1) && [Borrower DOB] <= Date(1945, 12, 31),
	"Silent Generation",
	IF(
		[Borrower DOB] >= Date(1946, 1, 1) && [Borrower DOB] <= Date(1964, 12, 31),
		"Baby Boomer",
		IF([Borrower DOB] >= Date(1965, 1, 1) && [Borrower DOB]) <= Date(1981, 12, 31),
		"Gen X",
		IF(
			[Borrower DOB] >= DATE(1982, 1, 1),
			"Millennials",
			YOU'RE MISSING SOMETHING HERE. AN IF STATEMENT REQUIRES 3 ARGUMENTS.
		)
	)
)
Moderator v-caliao-msft
Moderator

Re: Dax Statement: The end of the input was reached

Hi @DNA,

 

Please try the DAX below.

Age Group = 
If([borrower dob] >= Date(1930,1,1) && [borrower dob] <= Date(1945,12,31),"Silent Generation",
If([borrower dob] >= Date(1946,1,1) && [borrower dob] <= Date(1964,12,31),"Baby Boomer", 
If ([borrower dob] >= Date(1965,1,1) && [borrower dob] <= Date(1981,12,31),"Gen X","Millennials")))

Capture.PNG

 

 

Regards,

Charlie Liao

DNA Frequent Visitor
Frequent Visitor

Re: Dax Statement: The end of the input was reached

Thanks Charlie, that seemed to work. It looks like my statement needed to be fixed to have a third argument