The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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 |
---|---|
28 | |
11 | |
8 | |
6 | |
5 |
User | Count |
---|---|
35 | |
14 | |
12 | |
9 | |
7 |