- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

IFERROR in DQ
I am querying a datamart table and getting the following error
Function 'IFERROR' is not allowed as part of calculated column DAX expressions on DirectQuery models.
Sample Query
DEFINE
COLUMN t1[__sid] =
VAR int =
IFERROR (
VAR int = CONVERT ( t1[prop], INTEGER ) RETURN int,
0
)
RETURN
int & "-" & t1[__bid]
TABLE cust =
SUMMARIZECOLUMNS ( t1[ID], t1[__sid] )
EVALUATE
cust
How can I bypass this; as `t1[prop]` has mixed data types and IFERROR or equivalent of IFERROR needs to take place.
@AlexisOlson @bcdobbs @CNENFRNL
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

This isn't perfect but might be good enough...
You can format the mixed value as text and check if the first and last characters are digits before attempting to convert it to an integer.
VAR _Str = FORMAT ( t1[prop], "0" )
VAR _Digits_ = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
VAR _Int =
IF (
LEFT ( _Str ) IN _Digits_ && RIGHT ( _Str ) IN _Digits_,
CONVERT ( _Str, INTEGER ),
0
)
VAR _Result = "prefix" & _Int
RETURN
_Result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@AlexisOlson many thanks for the response and can't thank you enough for promptly replying. Apologies for the delayed response on my end.
Your approach is awesome. However bypassing DQ limitation for this particular use case is not easy. With your approach, I get this prompt now
Function 'CONTAINSROW' is not allowed as part of calculated column DAX expressions on DirectQuery models.
To bypass, instaed of the column, I have utilized my original expression in a Measure and it went through; e.g.
DEFINE
TABLE cust =
SUMMARIZECOLUMNS (
t1[ID],
"__sid",
VAR int =
IFERROR ( VAR int = CONVERT ( t1[prop], INTEGER ) RETURN int, 0 )
RETURN
int & "-" & t1[__bid]
)
EVALUATE
cust
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

This seems a bit odd. You're converting it to an integer and then into a string?
Can you give some representative examples of t1[prop] and desired t1[__sid]?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

This isn't perfect but might be good enough...
You can format the mixed value as text and check if the first and last characters are digits before attempting to convert it to an integer.
VAR _Str = FORMAT ( t1[prop], "0" )
VAR _Digits_ = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }
VAR _Int =
IF (
LEFT ( _Str ) IN _Digits_ && RIGHT ( _Str ) IN _Digits_,
CONVERT ( _Str, INTEGER ),
0
)
VAR _Result = "prefix" & _Int
RETURN
_Result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

@AlexisOlson many thanks for the response and can't thank you enough for promptly replying. Apologies for the delayed response on my end.
Your approach is awesome. However bypassing DQ limitation for this particular use case is not easy. With your approach, I get this prompt now
Function 'CONTAINSROW' is not allowed as part of calculated column DAX expressions on DirectQuery models.
To bypass, instaed of the column, I have utilized my original expression in a Measure and it went through; e.g.
DEFINE
TABLE cust =
SUMMARIZECOLUMNS (
t1[ID],
"__sid",
VAR int =
IFERROR ( VAR int = CONVERT ( t1[prop], INTEGER ) RETURN int, 0 )
RETURN
int & "-" & t1[__bid]
)
EVALUATE
cust
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Yeah, I've had issues with DirectQuery calculated columns multiple times, so I try to avoid them whenever I can.
Does it work for you if you expand the IN to use a bunch of || instead?
VAR _Str = FORMAT ( t1[prop], "0" )
VAR _L = LEFT ( _Str )
VAR _R = RIGHT ( _Str )
VAR _Int =
IF (
(
_L = "0"
|| _L = "1"
|| _L = "2"
|| _L = "3"
|| _L = "4"
|| _L = "5"
|| _L = "6"
|| _L = "7"
|| _L = "8"
|| _L = "9"
) &&
(
_R = "0"
|| _R = "1"
|| _R = "2"
|| _R = "3"
|| _R = "4"
|| _R = "5"
|| _R = "6"
|| _R = "7"
|| _R = "8"
|| _R = "9"
),
CONVERT ( _Str, INTEGER ),
0
)
VAR _Result = "prefix" & _Int
RETURN
_Result

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
01-16-2025 03:02 AM | |||
06-06-2024 09:31 AM | |||
Anonymous
| 08-26-2021 07:19 AM | ||
10-12-2021 01:56 AM | |||
Anonymous
| 04-26-2023 04:37 AM |
User | Count |
---|---|
107 | |
87 | |
80 | |
54 | |
46 |