Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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
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
I want to return 3 to 4 VAR in a single DAX calculated column
Only if you create a text concatenation of these values.
@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 @dinesharivalaga
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.
You can only RETURN a single scalar value. There is no other way.
Your switch function in return does not have any logical operator and that's why it's not switching.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
11 |
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |