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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

count if sum last 12 month are greater than 0

Hi all, 

 

I am trying count how many active employees in current month (based in the slicer selection) had bonus in the last 12 months. 

 

Exemple: 

If i select FEB/2021, i'd like to get the number of employees active in FEB/2021 which get bonus in the last 12 months (from FEB/2020 until JAN/2021) . 

 

I have a measure to calucalate the active employees per month which is working fine, and i create a measure to calculate the total of bonus paid in the last 12 months: 

 

 

CALCULATE( SUM(Bonus[Value]),
 DATESBETWEEN(_Calendar[DATE], 
FIRSTDATE ( PARALLELPERIOD ( _Calendar[DATE], -12, MONTH ) ), 
FIRSTDATE ( PARALLELPERIOD ( _Calendar[DATE], -1, MONTH ) ) ) )

 

 

The employee table and bonus table are linked by the employee ID. 

 

I tried to calcualte the number of active employee in the last 12 months with this kind of formula: 

CALCULATE ( [HC - employee] , [Bonus last 12 months] > 0 ) 

 

however is not possible to use measure or calculate as filter.  is there anyway i can achive it ? 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

In card visual,you need to generate a temporary table and then filter data in this  table, please change your new measure as below:

Measure_2 = 
VAR tab =
    SUMMARIZE ( bonus, Emploloyees[Name], "Headcount", [HEADCOUNT] )
RETURN
    CALCULATE ( [HEADCOUNT], FILTER ( tab, [Bonus paid] > 0 ) )

 

In table visual,you  can directly drag your field "measure" to visual pane to filter the data.

93.png

 

Best Regards,
Community Support Team _ Eason
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

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

In card visual,you need to generate a temporary table and then filter data in this  table, please change your new measure as below:

Measure_2 = 
VAR tab =
    SUMMARIZE ( bonus, Emploloyees[Name], "Headcount", [HEADCOUNT] )
RETURN
    CALCULATE ( [HEADCOUNT], FILTER ( tab, [Bonus paid] > 0 ) )

 

In table visual,you  can directly drag your field "measure" to visual pane to filter the data.

93.png

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

It worked like a glove. 

 

Thanks a lost for the help.

v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

Have you tried to use visual filter pane to filter the data?

I'm a little confused by your description.

Please share your sample data and expected output  which would help tremendously.

 

Best Regards,
Community Support Team _ Eason

 

 

Anonymous
Not applicable

Hi here is a sample of the pbix 

 

https://www.dropbox.com/s/9uh9z16ua41v9tm/sample.pbix?dl=0 

 

So what i am trying to achive is to have a measure whihc will return the number of  active employees who get bonus paid in the last 12 months. 

 

So as i put in the sample, i have: 

  • Table with employee data (ID, Name, start date and leaving date) 
  • Table with bonus paid montlhy (date, ID, amount) 

 

So I have a measure called HEADCOUNT, which return the number of active employees based in the calendar slice selection. 

 

I also have a measure called BONUS PAID, which returns the total of bonus paid in the last 12 months. 

 

Now based on the number of active employees for that month i need to caount how many get bonus paid in the last 12 monts. 

 

So the expected result would be: 

 

from the 5 employees that ate listed, I have 4 active in JUN/20 and out his 4 , 1 get 0 bonus amount in the last 12 months, so i would like to get as return 3, which reflects the number of employees active who got bonus in the last 12 months. 

 

I has trying to calculate it using the following DAX: 

 

Calculate( [HEADCOUNT], [BONUS PAID] > 0 ) 

 

however in the calulate expression is not possible to use a measure in the filter section. 

 

I also tried :

 

IF( BONUS>0, [HEADCOUNT])  however the result is giving me is 4. 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors