Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi, everyone! I have such a huge formula (in fact, it is much longer, about 80 lines, I shortened it here so that you can understand the essence). How can I make it more compact? Please advise any functions or solutions for this.
Solved! Go to Solution.
Hi @SErgey-kuznetso ,
You can use the || together with () to shorten your formula.
I think you can also use switch as your option.
company_part =
SWITCH(
TRUE(),
(DBExtras[name] = "Child chair (group 1)" ||
DBExtras[name] = "Booster (group 2/3)" ||
DBExtras[name] = "Infant seat (cradle)"), DBExtras[price] / 2,
DBExtras[name] = "SIM card" &&
(DBExtras[currency]="EUR" ||
DBExtras[currency]="USD"), DBExtras[count] * 2,
DBExtras[name] = "SIM card" &&
DBExtras[currency]="RUB", DBExtras[count] * 120,
DBExtras[name] = "Drinking water" &&
(DBExtras[currency]="EUR" ||
DBExtras[currency]="USD"), DBExtras[count] * 1,
DBExtras[name] = "Drinking water" && DBExtras[currency]="RUB", DBExtras[count] * 70
Hi @SErgey-kuznetso ,
You can use the || together with () to shorten your formula.
I think you can also use switch as your option.
company_part =
SWITCH(
TRUE(),
(DBExtras[name] = "Child chair (group 1)" ||
DBExtras[name] = "Booster (group 2/3)" ||
DBExtras[name] = "Infant seat (cradle)"), DBExtras[price] / 2,
DBExtras[name] = "SIM card" &&
(DBExtras[currency]="EUR" ||
DBExtras[currency]="USD"), DBExtras[count] * 2,
DBExtras[name] = "SIM card" &&
DBExtras[currency]="RUB", DBExtras[count] * 120,
DBExtras[name] = "Drinking water" &&
(DBExtras[currency]="EUR" ||
DBExtras[currency]="USD"), DBExtras[count] * 1,
DBExtras[name] = "Drinking water" && DBExtras[currency]="RUB", DBExtras[count] * 70
@SErgey-kuznetso You can create additional dictionary table with two columns: DBExtras[name] and multiplifer; then through LOOKUPVALUE extract proper values without lots of IFs.
User | Count |
---|---|
130 | |
108 | |
101 | |
67 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |