Forum Discussion
Variable in a calculate function not working
Hello,
I have a table where i used Eomonth() function to evaluate the past month up until one year from today's standpoint, equals to a specific number. For example the last month will me automatically evaluated as -1, two month before today's month is -2 and so fourth....
This value I have made accessible through a dropdown menu. Since I don't want to make a calculation for every month in a mesaure à la
if (selecetedvalues =-1 ......if selectedvalue=-2 then.....
I put it into a variable and only need to write the calculate function once:
VAR VALUE1 = SELECTEDVALUE('TableList'[Value1])
RETURN
CALCULATE(SUM('Table1'[ProductAmount]),
FILTER('Table1',
'Table1'[Quotation] = VALUE1)
)
The problem is it doesn't work. I get empty values. I double check with commenting out the caluclate function, if the variable is actually returning -1 when I set it to last month and it does. The card visual show the correct value. When I now write -1 directly into the calculate formula it works as well. So why it does not works intended?
VAR VALUE1 = SELECTEDVALUE('TableLIst'[Value1])
RETURN
CALCULATE(SUM('Table1'[ProductAmount]),
FILTER('Table1',
'Table1'[Month] = EDATE(DATE(YEAR(TODAY()),MONTH(TODAY()),1),VALUE1)
))
Here is also a Values1 as a Variable and I don't see any difference in evaluation.
I hope someone can understands whats happening here.
Best.
1 Reply
- AnonymousNot applicable
Hi Applicable88
I have no way to restore your scene, can you provide relevant data and table information ? Or provide a simple pbix file, and then attach the results you want. Maybe this will help us deal with the problem better.
Best Regards
Community Support Team _ Ailsa Tao