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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dinesharivalaga
Post Patron
Post Patron

Expressions that yield variant data-type cannot be used to define calculated columns

Hi Experts,

 

I am getting this error "Expressions that yield variant data-type cannot be used to define calculated columns" when using SWITCH(TRUE()) condition as below .

Key account Rule = SWITCH(TRUE(),([Total FY Forecast] > 500000),"Yes" ||
'Test Delivery Updates'[Delivery Model] = "Embedded","Yes" ||
'Test Delivery Updates'[PACE Account]="Yes","Yes" ||
'Test Delivery Updates'[Engagement run with DPOT]="Yes","Yes" ||
'Test Delivery Updates'[Account requires focus]="Yes","Yes")

dinesharivalaga_0-1726489971257.png


here i am resulting only text (Yes or No) but i don't know how this error occurred.

[Total FY Forecast] is Currency data type , rest all text data type

Please help to solve this ?

 

Thanks

DK



6 REPLIES 6
lbendlin
Super User
Super User

Your switch statement is malformed.

 

 

Key account Rule =
SWITCH (
    TRUE (),
    ( [Total FY Forecast] > 500000 ),
        "Yes"
            || 'Test Delivery Updates'[Delivery Model] = "Embedded",
    "Yes"
        || 'Test Delivery Updates'[PACE Account] = "Yes",
        "Yes"
            || 'Test Delivery Updates'[Engagement run with DPOT] = "Yes",
    "Yes"
        || 'Test Delivery Updates'[Account requires focus] = "Yes", "Yes"
)

 

You seem to have shifted the conditions and the values.

 

Please provide a more detailed explanation of what you are aiming to achieve. 

 

@lbendlin Thanks for your response 🙂

Actual requirement is below :

 

Key Account Logic :

-----------------

if "Delivery model"="Embedded" or Forecast > 500K ="Yes" or "PACE Account"="Yes" or "Engagement run with DPOT"="Yes" or "Account requires focus"="Yes" then it is key account.

 

All the accounts are having the above columns and if any one of the conditions is matched then the calcluated column will give YES else NO . I need to use this calculated column to filter pane to choose YES or NO.

 

Already having a measure : 

Total FY Forecast = SUMX(VALUES('Test Delivery Updates'[FY Forecast]),CALCULATE(DISTINCT('Test Delivery Updates'[FY Forecast]))) --> which is used in the SWITCH DAX .
 
 

 

 

Key account Rule =
IF ( [Total FY Forecast] > 500000  
     || [Delivery Model] = "Embedded" 
     || [PACE Account] = "Yes" 
     || [Engagement run with DPOT] = "Yes" 
     || [Account requires focus] = "Yes"
, "Yes","No"
)

 

Note:  You cannot (should not) use a measure to fill a calculated column. Calculated columns only have row context, not filter context.

 

@lbendlin  Error disappeared now when i used "IF" condition DAX but result is not as expected.

 

Actually we have to create 2 different Key Account logic columns to filter the accounts , I am using sharepoint list as a data source , in the list I have created a duplicate account and testing it if same account has 2 different forecast values even 2 different offer type and once it added into the table visual it should give only one account with sum of forecast values , if those sum value > 500k then it is Key Accounts else not a key account.

 

If i use "SWITCH" condition , i can able to see the result but error occurs.

 

Source :

dinesharivalaga_1-1726497499551.png

IF condition result : (FY forecast > 500k)

dinesharivalaga_2-1726497591743.png

 

SWITCH condition result : (FY forecast > 500k)  --> from source sum of 2 Abbott account forecast is > 500k , so it is matched the condition. hence it is displaying in the table chart.

dinesharivalaga_3-1726497777012.png

 

 DAX used in 2 different requirements:

Key account Rule = SWITCH (TRUE (),
    ( [Total FY Forecast] > 500000 ),
    "Yes"
            || 'Test Delivery Updates'[Delivery Model] = "Embedded",
    "Yes"
        || 'Test Delivery Updates'[PACE Account] = "Yes",
    "Yes"
            || 'Test Delivery Updates'[Engagement run with DPOT] = "Yes",
    "Yes"
        || 'Test Delivery Updates'[Account requires focus] = "Yes",
    "Yes"
)
 
Key Account Rule 1 =VAR keyaccountrule = CALCULATE([Total FY Forecast],ALLEXCEPT('Test Delivery Updates','Test Delivery Updates'[Account Name]))
RETURN
IF(keyaccountrule > 500000,"Yes","No")
 
Hope it is understandable for you now ..

Looks like you just repeated your earlier (incorrect) code. What would you like to get assistance with?

@lbendlin  Abbott account should be displayed in the table chart because it matched the condition (Forecast > 500k) , this is the expected result .

 

If i use SWITCH condition then the result is coming but also error occurs , if i use IF condition then the result is not coming (Abbott is missing) , so how to retrieve the correct result with any one of the above DAXs ?

For example :

Account  Offertype  forecast values  key accounts
AAAQ2334 
BBBQ34556 
CCCA675454 
AAAA499523 
DDDQ65454 
BBBA9453 


Row 1 : Account name is AAA, Offer type is Q and Forecast value is 2334
Row 4 : Account name is AAA , Offer type is A and Forecast value is 499523 then the sum of the AAA is >500K then it is "Yes". if row 1 & row 4 has less than 500K forecast value then it is "No" 

Same logic for row 2 & 6 , I need to add this calculated column "Key Accounts" into page filter pane and select Yes or No in different bookmarks. So the account name should be unique with summing forecast values when it publishing in the table visual (no duplicate account names displaying)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.