Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PshemekFLK
Helper IV
Helper IV

Flag measure for different hierarchy levels

Hello,

 

I have a list of customers that are grouped into distributors:

 

DistributorCustomer

Distributor A

Customer 1

Distributor ACustomer 2

OTHER

Customer 3
OTHERCustomer 4
OTHERCustomer 5

 

I created a measure to flag "Y" or "N" if customer have been active for the last 25 months. For every customer that doesn't belong to "OTHER" bucket the flag should say "Y" if the distributor is active even if customer isn't:

 

Active Flag =
VAR OtherSelected = IF(SELECTEDVALUE(dim_distributor[Distributor]="OTHER","Y","N")
VAR Formulaforother = IF([Months Active]>=25,"Y","N")
VAR Formulafordistributor = CALCULATE(IF([Months Active]>=25,"Y","N"),ALL(dim_distributor),VALUES(dim_distributor[Distributor])
 
RETURN
IF(SelectedOther="Y", Formulaforother, Formulafordistributor)

 

The problem with this formula is that if I filter a customer/distributor sales table on Active Flag = "Y" the Other bucket still shows sum of all customers even those that are not active. How to overcome that?

 

DistributorCustomerSalesActive Flag
OTHER

Customer 3

200Y

OTHER

Customer 4200Y
OTHERCustomer 5100N

 

Sum of all active customers should show 400, not 500:

 

DistributorSalesActive Flag
OTHER500Y

 

I can't create a calculated column for a flag as [Months Active] formula is dynamically changed by a slicer

1 REPLY 1
lbendlin
Super User
Super User

"CALCULATE(IF([Months Active]>=25,"Y","N"),ALL(dim_distributor),VALUES(dim_distributor[Distributor])"

 

This doesn't really calculate much apart from the ALL() statement which is likely also the culprit. I think you meant ALLSELECTED(). 

 

Anyway, please provide sample data in usable format (not as a picture - maybe insert into a table?) including the Month Active column, and show the expected outcome.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.