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
sk98lang
Regular Visitor

DAX to calculate previous month value but not for last month with acutals

Hi all. I would apprecitate your help with the following problem.

 

I get a monthly report from the HR department with a list of all employees. I would like to calculate the monthly changes and show them in a summary table as well as in a matrix visual on employee level (but here just the monthly changes).

 

In my fact table, I have currently employee data until July 2023. The fact table is connected to a date table (dates until 2025-Dec-31). I'm calculating the previous month value via the DATEADD function. By doing so, it also gives me also a previous month value for July 23 show under August 2023 in the summary table and matrix visual.

 

My question is: how do I have to manipulate the dax code for the "HC previous month" so that the previous month value for future months (where no actual data is yet available) is not shown in the visuals?


I have already tried if ([Headcount] = blank (), blank().... but this does not work for the matrix visual on employee level as once an employee left the headcount is blank and instead of -1 I get a blank value in respective month.

 

Thanks for your help.

 

sk98lang_1-1689936259009.png

 

 

1 ACCEPTED SOLUTION
sk98lang
Regular Visitor

Hi.

Thanks for your reply.

I did fix the problem at my own by using parts of this DAX pattern by Alberto/Marco (Custom time-related calculations – DAX Patterns).

 

Best regards, Sebastian

 

View solution in original post

2 REPLIES 2
sk98lang
Regular Visitor

Hi.

Thanks for your reply.

I did fix the problem at my own by using parts of this DAX pattern by Alberto/Marco (Custom time-related calculations – DAX Patterns).

 

Best regards, Sebastian

 

lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.