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

Variable not working although code is within an object

I have the following code:

 

MonthName(AddMonths(Today(),-1))

This gives me the previous month before the current date i.e. Jan 2021

This works when I place within a text box but not when I create it within a variable.

Any ideas welcome.

Many Thanks

Martin 

Labels (1)
1 Solution

Accepted Solutions
Chanty4u
MVP
MVP

or

sum({<Month={'$(vMonthname)'}>}Amount)

or

sum({<Month={$(=vMonthname)}>}Amount)

View solution in original post

8 Replies
edwin
Master II
Master II

when you display the content of the variable in a text box what do you see?  use =Variable without the $() evaluation

edwin
Master II
Master II

also how do you use the variable?  is it in set analysis?

Chanty4u
MVP
MVP

How you are creating variables?  

try this

 

vMonthname         =MonthName(AddMonths(Today(),-1))

 

you can use now

$(vMonthname) 

or

 $(=vMonthname)

 

if not share your variable details with small example.

martin_hamilton
Creator
Creator
Author

My intention is to use this within a set analysis, i.e.

=sum({<Invoice_Month={$(vMonthname) }>} Invoice_Amount)

If i populate with a hard coded date it works e.g.

=sum({<Invoice_Month={'Jan 2021' }>} Invoice_Amount)

Chanty4u
MVP
MVP

may be try this

 Sum({<Month = { '$( =$(vMonthname) )' }>}  [Amount])

 

 

Chanty4u
MVP
MVP

or

sum({<Month={'$(vMonthname)'}>}Amount)

or

sum({<Month={$(=vMonthname)}>}Amount)

martin_hamilton
Creator
Creator
Author

Thanks for your help. i played around with it and this seems to do the job:

 

=Sum({<Invoice_Month={"$(vPreviousMonth)"}>}Invoice_Amount)

 

This is where vPreviousMonth is:

=MonthName(AddMonths(Today(),-1))

Thanks for your help

Chanty4u
MVP
MVP

great !! 

have a nice day.