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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

RETURN multiple VAR results in DAX

Hi Experts,

I want to return 3 to 4 VAR in a single DAX calculated column based on the each VAR conditions. 

Below the formula i have used to apply.

Cost Status =
VAR CostSpentYTD = [Cost Spent YTD]
VAR PlannedCostYTD = [Planned cost YTD]
VAR OverallBudgetedCost = [Overall budgeted cost]
VAR NeededToComplete = [What is still needed to complete the project?]
VAR spentandpending = [Cost Spent YTD]+[What is still needed to complete the project?]
VAR budgetdeviation = OverallBudgetedCost - spentandpending
VAR CustomerDependency = [Is the budget overrun due to customer dependency/CG side?]
VAR InitialStatus =
SWITCH(
TRUE(),
ABS(CostSpentYTD-PlannedCostYTD) > PlannedCostYTD * 0.1, "Red",
ABS(CostSpentYTD-PlannedCostYTD) < PlannedCostYTD * 0.1, "Amber",
ABS(CostSpentYTD-PlannedCostYTD) = PlannedCostYTD * 0.1, "Green"
)
VAR BudgetStatus =
SWITCH(
TRUE(),
ABS(budgetdeviation) > OverallBudgetedCost*0.1,"Red",
ABS(budgetdeviation) < 0 && budgetdeviation > OverallBudgetedCost*0.1,"Amber",
"Green"
)
VAR CombinedStatus =
SWITCH(
TRUE(),
CustomerDependency = "Customer" && (InitialStatus = "Red" || BudgetStatus = "Red"), "Amber",
CustomerDependency = "CG" && (InitialStatus = "Red" || BudgetStatus = "Red"), "Red","Green"
)
RETURN
SWITCH(TRUE(),
InitialStatus,BudgetStatus,CombinedStatus
)


The above DAX is returing error .. the below table is the output , now i have returned only Initialstatus VAR , so that 1st 2 rows are giving exact results and rest all 4 rows are just applied the RED based on the Otherwise "Red" condition

dinesharivalaga_0-1729690221963.png

Expected result is : order from top
Amber , Green , Red , Amber , Amber , Green 

 

I have all the above scenarios in each account names in the above sample table , so whenever the above SWITCH conditions are matched then all the 3 created VAR should apply the logics and produced the results. At a single time cannot able to showcase all Variables.
Few more conditions are yet to develop but please so far help me to showcase above 3 VARs in a DAX which i created.

 

Thanks

DK

5 REPLIES 5
lbendlin
Super User
Super User

I want to return 3 to 4 VAR in a single DAX calculated column

 

Only if you create a text concatenation of these values.

Anonymous
Not applicable

@lbendlin  yes but in the table , all the accounts has a matched conditions , so if we use text concat then it will be something based on the results right ?
Can you please help me to suggest idea based on my conditions ?

Hi @Anonymous 
try below DAX
Cost Status =
VAR CostSpentYTD = [Cost Spent YTD]
VAR PlannedCostYTD = [Planned cost YTD]
VAR OverallBudgetedCost = [Overall budgeted cost]
VAR NeededToComplete = [What is still needed to complete the project?]
VAR spentandpending = [Cost Spent YTD]+[What is still needed to complete the project?]
VAR budgetdeviation = OverallBudgetedCost - spentandpending
VAR CustomerDependency = [Is the budget overrun due to customer dependency/CG side?]
VAR InitialStatus =
SWITCH(
TRUE(),
ABS(CostSpentYTD-PlannedCostYTD) > PlannedCostYTD * 0.1, "Red",
ABS(CostSpentYTD-PlannedCostYTD) < PlannedCostYTD * 0.1, "Amber",
ABS(CostSpentYTD-PlannedCostYTD) = PlannedCostYTD * 0.1, "Green"
)
VAR BudgetStatus =
SWITCH(
TRUE(),
ABS(budgetdeviation) > OverallBudgetedCost*0.1,"Red",
budgetdeviation < 0 && ABS(budgetdeviation )> OverallBudgetedCost*0.1,"Amber",
"Green"
)
VAR CombinedStatus =
SWITCH(
TRUE(),
CustomerDependency = "Customer" && (InitialStatus = "Red" || BudgetStatus = "Red"), "Amber",
CustomerDependency = "CG" && (InitialStatus = "Red" || BudgetStatus = "Red"), "Red","Green"
)
RETURN
SWITCH(TRUE(), 

[Planned cost YTD]<>blank(),InitialStatus,
[Is the budget overrun due to customer dependency/CG side?]<>blank(),CombinedStatus,

BudgetStatus
)
let me know if this works as expected or not.



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

You can only RETURN a single scalar value. There is no other way.

Rupak_bi
Super User
Super User

Hi @Anonymous 

Your  switch function in return does not have any logical operator and that's why it's not switching. 



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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