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
Applicable88
Impactful Individual
Impactful Individual

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?

 
But that strangely works and I don't know why:
 

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 1
v-yetao1-msft
Community Support
Community Support

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

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.