Forum Discussion
Sample unification
- 9 months ago
Hi Veronika3 ,
This version fully consolidates the original formulas and handles all filter combinations correctly. The only adjustment needed was in the no filter fallback, where the original logic used the lowercase keyc and CountCustomersc columns. After aligning that part, the consolidated SWITCH version matches the behavior of formulas A and B in every scenario and removes the repeated conditions from the original expressions.
Try this version, which fully consolidates the original logic and matches all filter scenarios -NC First Consolidated =
VAR hasCat = ISFILTERED(factNewBrand[PrimaryCategoryName])
VAR hasBrand = ISFILTERED(dimBrand[BrandName])
VAR hasManu = ISFILTERED(dimBrand[ManufacturerName])
VAR useBoth = hasCat && (hasBrand || hasManu)RETURN
SWITCH(
TRUE(),useBoth,
SUMX(
DISTINCT(factNewBrand[KeyB]),
FIRSTNONBLANK(factNewBrand[CountCustomersCB], 0)
),hasCat,
SUMX(
DISTINCT(factNewBrand[KeyC]),
FIRSTNONBLANK(factNewBrand[CountCustomersC], 0)
),hasBrand || hasManu,
SUMX(
DISTINCT(factNewBrand[KeyB]),
FIRSTNONBLANK(factNewBrand[CountCustomersB], 0)
),-- Default (no filters) – matches original formula B exactly
SUMX(
DISTINCT(factNewBrand[Keyc]),
FIRSTNONBLANK(factNewBrand[CountCustomersc], 0)
)
)
Thanks.
Hi Veronika3 ,
This version fully consolidates the original formulas and handles all filter combinations correctly. The only adjustment needed was in the no filter fallback, where the original logic used the lowercase keyc and CountCustomersc columns. After aligning that part, the consolidated SWITCH version matches the behavior of formulas A and B in every scenario and removes the repeated conditions from the original expressions.
Try this version, which fully consolidates the original logic and matches all filter scenarios -
NC First Consolidated =
VAR hasCat = ISFILTERED(factNewBrand[PrimaryCategoryName])
VAR hasBrand = ISFILTERED(dimBrand[BrandName])
VAR hasManu = ISFILTERED(dimBrand[ManufacturerName])
VAR useBoth = hasCat && (hasBrand || hasManu)
RETURN
SWITCH(
TRUE(),
useBoth,
SUMX(
DISTINCT(factNewBrand[KeyB]),
FIRSTNONBLANK(factNewBrand[CountCustomersCB], 0)
),
hasCat,
SUMX(
DISTINCT(factNewBrand[KeyC]),
FIRSTNONBLANK(factNewBrand[CountCustomersC], 0)
),
hasBrand || hasManu,
SUMX(
DISTINCT(factNewBrand[KeyB]),
FIRSTNONBLANK(factNewBrand[CountCustomersB], 0)
),
-- Default (no filters) – matches original formula B exactly
SUMX(
DISTINCT(factNewBrand[Keyc]),
FIRSTNONBLANK(factNewBrand[CountCustomersc], 0)
)
)
Thanks.
- Veronika39 months agoRegular Visitor
Thanky you, it works :).