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
Anonymous
Not applicable

Count of In-Active customers' measure

I have our distributors and their chemist sales data and want to count how many chemist were in-active in a given range (in months). For illustration I have attached the sample data and pbix file. 

Please create a measue which gives the total no. of chemists (to be placed in card visual) where no sale was made (in-Active) within 3, 6, 9 or 12 months.

 

The period duration is coming through a measure as you can also see from the pbix file.

 

https://www.dropbox.com/sh/oskyjt71nwnizj8/AABCD5H_j1VHrugPia3MKsSla?dl=0

 

 

Regards,

 

 

 

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try the below measure or see the attached file.

in-active count = 
VAR _period = SELECTEDVALUE( 'Period (in months)'[Period (in months)] )
VAR _end = TODAY()
VAR _start = DATE( YEAR( _end ), MONTH( _end ) - _period, DAY( _end ) )
VAR _active =
    CALCULATE( 
        DISTINCTCOUNT( Daily_Sales[Cust_Code] ),
        TREATAS(
            CALENDAR( _start, _end ),
            'Calendar'[Date]
        ),
        Daily_Sales[Value] > 0 -- remove if you want to include returns
    )
RETURN DISTINCTCOUNT( Daily_Sales[Cust_Code] ) - _active

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



 

View solution in original post

1 REPLY 1
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

Try the below measure or see the attached file.

in-active count = 
VAR _period = SELECTEDVALUE( 'Period (in months)'[Period (in months)] )
VAR _end = TODAY()
VAR _start = DATE( YEAR( _end ), MONTH( _end ) - _period, DAY( _end ) )
VAR _active =
    CALCULATE( 
        DISTINCTCOUNT( Daily_Sales[Cust_Code] ),
        TREATAS(
            CALENDAR( _start, _end ),
            'Calendar'[Date]
        ),
        Daily_Sales[Value] > 0 -- remove if you want to include returns
    )
RETURN DISTINCTCOUNT( Daily_Sales[Cust_Code] ) - _active

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski



 

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.