Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Workaround for IFERROR in DAX using DirectQuery

I'm currently migrating a PBI report from Import mode to DirectQuery. But apparently this mode doesn't have IFERROR. Is there another function/workaround for this issue? The column is defined as follows:

 

value =
VAR z = MIN(
MAX(
IFERROR(
RELATED('Table'[x]),
BLANK()),
0.1),
10000000)*[y]
RETURN IF(z>=2000,
ROUND(z,-2),
IF(z>1,
ROUND(z,0),
IF(z=0,
0,
1
)
)
)
6 REPLIES 6
daxer-almighty
Solution Sage
Solution Sage

Yes, RELATED works in DQ as one can check in dax.guide. But why would you expect RELATED to throw an error? That is what bothers me a lot since this means you're not sure if there's going to be a relationship between the tables. By the by, one can easily remove RELATED and use LOOKUPVALUE instead.

amitchandak
Super User
Super User

@Anonymous , I doubt even related will work in the direct query in a column , You may have convert this into a measure

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak I tried to convert it into a measure. Now the error is the following:
The column 'Table[x]' either doesn't exist or doesn't have a relationship to any table available in the current context.

 

The weird thing is that the column exists. Not only that but I also have a relationship between the current table and the main 'Table', with cardinality *:1, with cross filter direction on "Both" and the relationship is active.

@Anonymous , Try like

 

value =
VAR z = MINX('Table2',
MAXX('Table2',
IFERROR(
RELATED('Table'[x]),
BLANK()),
0.1),
10000000)*[y]
RETURN IF(z>=2000,
ROUND(z,-2),
IF(z>1,
ROUND(z,0),
IF(z=0,
0,
1
)
)
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

I tried to remove the numbers on the MAXX and MINX, now both functions have 2 arguments. But the error is:

OLE DB or ODBC error: Exception from HRESULT: 0x80040E57

Anonymous
Not applicable

@amitchandak Tried it, but there's another error:

Too many arguments were passed to the MAXX function. The maximum argument count for the function is 2.

 

The thing is, I need to find the highest (and lowest with MIN function) between two expression, not only in a certain column.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.