Forum Discussion
IF statement as measure
- 6 years ago
Sorry, I meant try the substitution in your orginal measure, (excluding the && FIRSTNONBLANK part...)
- 6 years ago
hi o59393
The problem is that the data type of these columns 'Suppliers Compliance'[Audit Score (2] , 'Suppliers Compliance'[CAP Score (5_x] ,'Suppliers Compliance'[QF Score (20_x] , 'Suppliers Compliance'[Score Threats _x0028] , 'Suppliers Compliance'[Score Analysis _x002] are Text.
Then just change the data type of these columns to Number and use this formula
Q/FS Total DAX = var _package = (SUM('Suppliers Compliance'[Audit Score (2]) + SUM('Suppliers Compliance'[CAP Score (5_x]) + SUM('Suppliers Compliance'[QF Score (20_x]) + SUM('Suppliers Compliance'[Score Threats _x0028]) + SUM('Suppliers Compliance'[Score Analysis _x002]) ) /70 var _ingredients = (SUM('Suppliers Compliance'[Audit Score (2]) + SUM('Suppliers Compliance'[CAP Score (5_x]) + SUM('Suppliers Compliance'[QF Score (20_x]) + SUM('Suppliers Compliance'[Score Threats _x0028]) ) /70 return IF( SELECTEDVALUE( 'Suppliers Compliance'[Type] ) = "Ingredients", _ingredients , _package)Result:
Regards,
Lin
HASONEVALUE returns true or false, but the condition you've written is HASONEVALUE('Suppliers Compliance'[Type])= "Ingredients" which not only will never evaluate to true, but will almost certainly cause a type conversion error since it's comparing text to a boolean value. I think perhaps what you were thinking of would be better written as something like:
IF(HASONEVALUE('Suppliers Compliance'[Type]) && FIRSTNONBLANK('Suppliers Compliance'[Type], 1) = "Ingredients"
By the way if you ever get a visual error like that, click the See Details link in the error message and share the details too. That can sometimes narrow down the problem.
- o593936 years ago
Post Prodigy
hi!
Still got an error, I attach the pbix
https://1drv.ms/u/s!ApgeWwGTKtFdhjBPLkc9NFaUMyzB?e=YVZrx5
Thanks!
- PaulDBrown6 years ago
Community Champion
Try subsituting the HASONEVALUE for SELECTEDVALUE in your if statement
- o593936 years ago
Post Prodigy