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
Gaurav_Lakhotia
Helper III
Helper III

Active Company Count

Hello Everyone!!

Need your help in solving my problem, I'm trying to calculate/create a table which will give me distinct count of companies which are associated with me for particular year.

For example,

Capture11.PNG

 

In above snapshot, we have Join Year and End Year. We're marking "9999" for the companies who are still associated with us and we've proper year if they are terminated. Company with End Year "9999" should be counted in next years.

 

Result would be something like this,

Category20162017201820192020
Mobility12123
Insurance12422
Technology12322
Stationary11112

 

Here is the file with Sample Data .

 

Thanks in advance 🙂

1 ACCEPTED SOLUTION
v-xulin-mstf
Community Support
Community Support

Hi @Gaurav_Lakhotia,

 

Create a dimensional table as:

Table =

VALUES('Company Tbl'[Join Year])

Try measure as:

Measure =

CALCULATE(

    COUNT('Company Tbl'[Category]),

    FILTER(

        ALL('Company Tbl'),

         'Company Tbl'[Join Year]<=MAX('Table'[Year]) && 'Company Tbl'[End Year]>=MAX('Table'[Year]) && 'Company Tbl'[Category]=MAX('Company Tbl'[Category])

))

Here is the output:

v-xulin-mstf_0-1611807409317.png

 

Here is the demo, please try it: Active Company Count

Best Regards,

Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xulin-mstf
Community Support
Community Support

Hi @Gaurav_Lakhotia,

 

Create a dimensional table as:

Table =

VALUES('Company Tbl'[Join Year])

Try measure as:

Measure =

CALCULATE(

    COUNT('Company Tbl'[Category]),

    FILTER(

        ALL('Company Tbl'),

         'Company Tbl'[Join Year]<=MAX('Table'[Year]) && 'Company Tbl'[End Year]>=MAX('Table'[Year]) && 'Company Tbl'[Category]=MAX('Company Tbl'[Category])

))

Here is the output:

v-xulin-mstf_0-1611807409317.png

 

Here is the demo, please try it: Active Company Count

Best Regards,

Link

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

You need a calendar table (just years in your case).  Do not join it to the data table. Then write a measure, something like this


Result = sumx(dataTable,

If(Calendar[Year] >= dataTable[Join Year] && Calendar[Year] <=dataTable[end year],1))

 

put calendar year on columns in the matrix. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Hey @MattAllington , Sorry for late response, I thought I've turned On the notification. 

Didn't get the expected result with this.

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.