Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago

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

  • jthomson's avatar
    jthomson
    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?

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft 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.