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
Michalison
Helper I
Helper I

Calculation error in measure

I am trying to do a measure that filters employees who resigned and leaving date > 01/01/2021

 

Count Resignations = CALCULATE(COUNT(Personnel_Records[Resignation]),FILTER('Personnel_Records','Personnel_Records'[Resignation]="1" && (Personnel_Records[Leaving Date]>"01/01/2021"))
 
When I do this I get the follwing error
 

Calculation error in measure 'Calculation'[Count Resignations]: DAX comparison operations do not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

Can anyone help me on this as I don't know the correc

1 ACCEPTED SOLUTION
AUaero
Responsive Resident
Responsive Resident

Maybe just a copy/paste error, but your calculation is missing a closing parentheses.  What is the data type of Personnel_Records[Resignation]?  If it's not a string then there's no need to enclose the 1 in double quotes.  You can also try passing the date to the [Leaving Date] explicitly as a date.

CALCULATE(
	COUNT(Personnel_Records[Resignation]),
	FILTER(
		'Personnel_Records',
		'Personnel_Records'[Resignation] = 1 && 
		'Personnel_Records'[Leaving Date] > DATE(2021, 1, 1)
	)
)



View solution in original post

4 REPLIES 4
AUaero
Responsive Resident
Responsive Resident

Maybe just a copy/paste error, but your calculation is missing a closing parentheses.  What is the data type of Personnel_Records[Resignation]?  If it's not a string then there's no need to enclose the 1 in double quotes.  You can also try passing the date to the [Leaving Date] explicitly as a date.

CALCULATE(
	COUNT(Personnel_Records[Resignation]),
	FILTER(
		'Personnel_Records',
		'Personnel_Records'[Resignation] = 1 && 
		'Personnel_Records'[Leaving Date] > DATE(2021, 1, 1)
	)
)



Many thanks that worked perfectly

HotChilli
Super User
Super User

Quotes ("").  Comparisons need to be done on the same datatype

How do I do this? - sorry teaching myself PoeerBI as I go along

 

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.