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!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
Hello,
I need assistance creating a measure that dynamically calculates client status based on a date selection in my report.
I need to classify each client into these status categories:
I've attached sample data to demonstrate the scenario. Since the status needs to update based on the date selected in my report (not a fixed date), I need this as a measure rather than a calculated column.
Can someone help me create the appropriate measure for this dynamic classification?
Thank you!
MaxSelectedDate = MAX('Dates'[Date])
ClientFirstTradeDate =
CALCULATE(
MIN('Trading Data'[TransactionDate]),
ALLEXCEPT('Trading Data', 'Trading Data'[ClientID])
)
ClientLastTradeDate =
CALCULATE(
MAX('Trading Data'[TransactionDate]),
ALLEXCEPT('Trading Data', 'Trading Data'[ClientID])
)
ClientStatus =
VAR _SelectedDate = [MaxSelectedDate]
VAR _FirstTradeDate = [ClientFirstTradeDate]
VAR _LastTradeDate = [ClientLastTradeDate]
VAR _MonthsSinceFirstTrade = DATEDIFF(_FirstTradeDate, _SelectedDate, MONTH)
VAR _MonthsSinceLastTrade = DATEDIFF(_LastTradeDate, _SelectedDate, MONTH)
RETURN
SWITCH(
TRUE(),
-- Condition for Lost Client: Not traded for more than 6 months
_MonthsSinceLastTrade > 6, "Lost Client",
-- Condition for New Client: First trade is in the selected period (0 months of trading)
_MonthsSinceFirstTrade = 0, "New Client",
-- Condition for NBTO (New But Trading Once): Traded for <= 12 months
_MonthsSinceFirstTrade <= 12, "NBTO",
-- Condition for Existing Client: Traded for > 12 months
_MonthsSinceFirstTrade > 12, "Existing Client",
"Inactive"
)
Hi @InsightSeeker
Try below measure
Status =
var max_month=MAX('Calendar Ultimate'[Date])
//trading dates for last 13 months
var existing_client_dates=DATESINPERIOD('Calendar Ultimate'[Date],max_month,-13,MONTH)
//trading dates for last 12 months
var nbto_dates=DATESINPERIOD('Calendar Ultimate'[Date],max_month,-12,MONTH)
//trading dates for last 6 month
var lost_client_dates=DATESINPERIOD('Calendar Ultimate'[Date],TODAY(),-6,MONTH)
var res_existing_client=CALCULATE(COUNT(data[Order_Number]),existing_client_dates)
var res_newclient=CALCULATE(COUNT(data[Order_Number]),'Calendar Ultimate'[Date]=max_month)
var res_nbto=CALCULATE(COUNT(data[Order_Number]),nbto_dates)
var res_lost_client=CALCULATE(COUNT(data[Order_Number]),lost_client_dates)
RETURN
SWITCH(
TRUE(),
NOT ISBLANK(res_existing_client),"Existing CLient", //more than 12 months
NOT ISBLANK(res_nbto),"NBTO", //less than equal to 12 months
NOT ISBLANK(res_newclient),"NBTO", //zero month
ISBLANK(res_lost_client) || res_lost_client=0,"Lost CLient" //more than 6 month
)
please give kudos or mark it as resolved once confirmed