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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Month over month using measure instead of column

I am trying to get a month over month increase over a year timeframe with a measure. I have seem videos where they use yearYTD function with calculate, but in all these circumstances they have a column that is connected to the date column. In my case, I cannot connect the relationship and I am using a measure instead of a column. 

The measure I have is terminations/active employees. This measure gives a percent per month for the year. It shows employee turnover per month. I also wanted to have a percent that grows throughout the year. So taking the begining of the year number and adding to it throughout the year. I am using userrelationships to connect the termination date with the active count. 
 

Let me know what more information I can provide. 

 

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

If the screenshot below is your desired result for employee count, this can still be implemented using an active relationship between the dates table and hire date column.

You can use CROSSFILTER to disable any existing relationship within a measure.

Employee Count =
VAR selectedDate =
    MAX ( 'Date Table'[Date] )
RETURN
    CALCULATE (
        SUMX (
            data,
            VAR employeeStartDate = data[Hire Date ]
            VAR employeeEndDate = data[Termination Date]
            RETURN
                IF (
                    employeeStartDate <= selectedDate
                        && OR ( employeeEndDate >= selectedDate, employeeEndDate = BLANK () ),
                    1
                )
        ),
        CROSSFILTER ( 'Date Table'[Date], data[Hire Date ], NONE )
    )

 

or this approach sans the active relationship

Employee Count2 = 
VAR selectedDate =
    MAX ( 'Date Table'[Date] )
VAR result =
    CALCULATE (
        COUNTROWS ( data ),
        FILTER (
            FILTER ( ALL ( data ), data[Hire Date ] <= selectedDate ),
            data[Termination Date] >= selectedDate
                || data[Termination Date] = BLANK ()
        )
    )
RETURN
    result

danextian_0-1662429883443.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

@danextian, I was wondering if you may know how to now do a running total of the numbers from that file? I noticed doing it from a measure instead of a column is much harder. Any ideas on that? 

Using the same data, can you please post a snapshot or your desired result?





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
danextian
Super User
Super User

Hi @Anonymous ,

 

Can you please post a sanitized sample pbix of your data model?

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/2733012#M953338 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Here is an example of what I created. The turnover is correct. You will notice in the file that there is not an active relationship with the two tables. This needs to be the case in order to get the correct turnover percentage as its comparing the hire date and termination date. But in not having it connected, it makes it difficult to get a running total. I tried two different approaches from the file attached, but neither of them give me the correct results. it should show a total of previous months moving foward for the year or a timeframe filtered. 


 https://drive.google.com/file/d/1lkVybQZgvceugLA1oU1pzhZgRhCVWeuw/view?usp=sharing

 

If I understood correctly and using the data below, the total employee count if the selected date is 24 Feb 2021 is 4 and the turnover rate should be 0% as none of them has been terminated yet?

danextian_0-1662083852845.png

Also, why can't you create an active relationship but an inactive one is okay?

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Anonymous
Not applicable

Hi Danextian, yes so you can do it manually as well to confirm the numbers, but you take the termination count for the month and then divide by the active count for that month to get the percentage. 

 

If you go in and activate the relationship, you will see the numbers change that will no longer match up with the numbers not in the relationship. 

Hi @Anonymous 

If the screenshot below is your desired result for employee count, this can still be implemented using an active relationship between the dates table and hire date column.

You can use CROSSFILTER to disable any existing relationship within a measure.

Employee Count =
VAR selectedDate =
    MAX ( 'Date Table'[Date] )
RETURN
    CALCULATE (
        SUMX (
            data,
            VAR employeeStartDate = data[Hire Date ]
            VAR employeeEndDate = data[Termination Date]
            RETURN
                IF (
                    employeeStartDate <= selectedDate
                        && OR ( employeeEndDate >= selectedDate, employeeEndDate = BLANK () ),
                    1
                )
        ),
        CROSSFILTER ( 'Date Table'[Date], data[Hire Date ], NONE )
    )

 

or this approach sans the active relationship

Employee Count2 = 
VAR selectedDate =
    MAX ( 'Date Table'[Date] )
VAR result =
    CALCULATE (
        COUNTROWS ( data ),
        FILTER (
            FILTER ( ALL ( data ), data[Hire Date ] <= selectedDate ),
            data[Termination Date] >= selectedDate
                || data[Termination Date] = BLANK ()
        )
    )
RETURN
    result

danextian_0-1662429883443.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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