Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi @sarahomar955 ,
Please try:
Total_Customers_2 =
VAR Base = [notselected_customers] + [AllActuals]
VAR SelectedLine =
SELECTEDVALUE ( 'SBI Actuals Agg (x100)'[Line of Items] )
VAR Result =
SWITCH (
SelectedLine,
"[NE]", CALCULATE ( [Nes_time_new] + Base ),
"[L66]", CALCULATE ( [L6_time_new] + Base ),
"[L66b]", CALCULATE ( [L6b_time_new] + Base ),
"[C11]", CALCULATE ( [c1_time_new] + Base ),
"[L110]", CALCULATE ( [L10_time_new] + Base ),
{ [GE], "[L66a]", "[L1]", "[L2]", "[L3]", "[Net Weight]" }, [Fixed_Date_Total_Customers] + [AllActuals],
"[L14]", CALCULATE ( [L14_time_new] + Base ),
"C1", [c1PerNes_total]
)
VAR NumericValue =
IF ( ISNUMBER ( Result ), Result, [Fixed_Date_Total_Customers] + [AllActuals] )
RETURN
FORMAT ( NumericValue, "#,##0" )
Optimizing IF conditions by using variables - SQLBI
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Use DAX Studio to examine the query plan for that query and then see if you can refactor it.
Note that "SELECTEDVALUE" needs to be complemented with TREATAS filters.
User | Count |
---|---|
14 | |
10 | |
7 | |
6 | |
5 |
User | Count |
---|---|
30 | |
19 | |
12 | |
7 | |
5 |