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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Filtering based on filtered values

Hi All,

 

I am stuck in a problem. Here are the details. I have a sales data which has sales with customer name and order date fields. I need to count customer which were active 4 months ago but are not active now. Basically I need to find lost values. E.g

If my data set has maximum order date as 30th November then 4 month ago i.e July 1st to July 31 who were the active customer then and out of those how many are active now. The difference is lost customers.
Data
Customer  Date

A              2nd July
B               4th July
C               10th July
D                20th July
A                10th November
B                  20th November
Here A,B,C,D were active 4 months ago but now only A and B are active. Basically we have 2 lost customer. I want to filter based on filtered active customer.        

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

You can create a calculated column as below:

Active customer = 
VAR _maxorddate =
    CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Table' ) )
RETURN
    CALCULATE (
        MAX ( 'Table'[Customer] ),
        FILTER (
            SUMMARIZE (
                'Table',
                'Table'[Customer],
                "ConL", CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) )
            ),
            DATEDIFF ( [ConL], _maxorddate, MONTH ) < 4
        )
    )

Filtering based on filtered values.JPGIf the above one is not applicable for your scenario, please provide your expected result with more explanation. Thank you.

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

You can create a calculated column as below:

Active customer = 
VAR _maxorddate =
    CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Table' ) )
RETURN
    CALCULATE (
        MAX ( 'Table'[Customer] ),
        FILTER (
            SUMMARIZE (
                'Table',
                'Table'[Customer],
                "ConL", CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[Customer] ) )
            ),
            DATEDIFF ( [ConL], _maxorddate, MONTH ) < 4
        )
    )

Filtering based on filtered values.JPGIf the above one is not applicable for your scenario, please provide your expected result with more explanation. Thank you.

Best Regards

amitchandak
Super User
Super User

@Anonymous , With the help from date table and time intelligence . Create measures like

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-4,MONTH)))

 

Not active now = countx(values(Table[Customer]), if(isblank([MTD Sales]) && not(isblank(last MTD Sales)),Table[Customer], blank()))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.