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
Anonymous
Not applicable

Issue with DAX Nested IF Statements in "Add custom column" from Access source

I have an .xls sheet with 460000 rows, and a rather complex if statement in a added custom column. 

 

Heres the statement:

= Table.AddColumn(#"Added Custom", "Korr_konto", each if [Konto] = "9200" and [FORMÅL] = "10; Debiterbart" then "9200a"
else if [Konto] = "9200" and [FORMÅL] <> "10; Debiterbart" and [Deb.typ] = "10; Debiterbar" then "9200b"
else if [Konto] = "9200" and [FORMÅL] <> "10; Debiterbart" and [Deb.typ] = "20; Ej debiterbar" then "9200c"
else if [Konto] = "7100" and [FORMÅL] = "10; Debiterbart" then "7100a"
else if [Konto] = "7100" and [FORMÅL] <> "10; Debiterbart" then "7100b"
else if [Konto] = "7110" and [FORMÅL] = "10; Debiterbart" then "7110a"
else if [Konto] = "7110" and [FORMÅL] <> "10; Debiterbart" then "7110b"
else if [Konto] = "7142" and [FORMÅL] = "10; Debiterbart" then "7142a"
else if [Konto] = "7142" and [FORMÅL] <> "10; Debiterbart" then "7142b"
else if [Konto] = "7143" and [FORMÅL] = "10; Debiterbart" then "7143a"
else if [Konto] = "7143" and [FORMÅL] <> "10; Debiterbart" then "7143b"
else if [Konto] = "7160" and [FORMÅL] = "10; Debiterbart" then "7160a"
else if [Konto] = "7160" and [FORMÅL] <> "10; Debiterbart" then "7160b"
else if [Konto] = "7161" and [FORMÅL] = "10; Debiterbart" then "7161a"
else if [Konto] = "7161" and [FORMÅL] <> "10; Debiterbart" then "7161b"
else if [Konto] = "7162" and [FORMÅL] = "10; Debiterbart" then "7162a"
else if [Konto] = "7162" and [FORMÅL] <> "10; Debiterbart" then "7162b"
else [Konto])

 

It works fine, but when I imported the rows into an Access DB and switched source I get an error message when I try to refresh the data on the "Add column" step (the data/colums/types are identical):

"DataFormat.Error: Expression too complex in query expression 'switch(
        ([_].[Konto] = '9200' and [_].[Konto] is not null) and ([_].[FORMÅL] = '10; Debiterbart' and [_].[FORMÅL] is not null), '9200a',
        (([_].[Konto] = '9200' and [_].[Konto] is not null) and ([_].[FORMÅL] <> '10; Debiterbart' or [_].[F'.
Details:
    Hovedboktrans_database.accdb"

 

When I shorten down the if statement to include only 14 (instead of 17) if statements it works fine.... Any ideas as to why?

2 REPLIES 2
Eric_Zhang
Employee
Employee

@Anonymous

It seems a nested if limitation from Access end, see some typical threads. Please find more constructive advice from the dedicated Access forum.

In my opinion, you can take the workaround in above post.

jthomson
Solution Sage
Solution Sage

I'm not sure on why it's doing this, but as a work around could you not make two columns, one looking at the first half of your statement, the other the second, returning nulls if applicable and then merge the two columns?

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.