Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
EDIT:
Thank you all for the help, but I just found a solution for my problem
_________________________________________________________________________________________
Hi.
I have 2 tables:
Table Team: that has 3 columns: the names of the employees, their date of admission and, if applied, the date when they left the company
Table BSC: that has 2 columns: years and months, since 2020
I want to know how long my employees stayed in my company at the different dates on the BSC table. To simplify, for now, I am not considering the date they left the company. I created a representation on excel to make it simpler to understand.
Basically for each combination of year/month in my BSC table, I create a new column in the BSC table with sum of the difference between the last day of that month and the date of admission for all my employees.
My DAX code would look like this:
Column = CALCULATE( SUMX (Team, Team[dateofadmission] - DATE( BSC[year], BSC[month], DAY(EOMONTH(DATE(BSC[year], BSC[month],1),0)) , FILTER (...) )
The problem with this formula is that I can't retrieve the columns from both of my tables. Do you have any idea of how I can calculate this?
Thank you
Solved! Go to Solution.
Hi @Anonymous
something like this
NewMeasure =
VAR CurrentMonth =
SELECTEDVALUE ( BSC[month] )
VAR CurrentYear =
SELECTEDVALUE ( BSC[year] )
VAR CurrentDate =
DATE ( CurrentYear, CurrentMonth, DAY ( EOMONTH ( DATE ( CurrentYear, CurrentMonth, 1 ), 0 ) ) )
RETURN
SUMX (
Team,
VAR StartDate = Team[dateofadmission]
VAR EndDate =
IF (
ISBLANK ( Team[dateoftermination] ),
CurrentDate,
MAX ( CurrentDate, Team[dateoftermination] )
)
RETURN
EndDate - StartDate
)
Hi @Anonymous
why don't you just creat a table visual as a measure?
I'm sorry, but can you explain better how to do that?
Hi @Anonymous
something like this
NewMeasure =
VAR CurrentMonth =
SELECTEDVALUE ( BSC[month] )
VAR CurrentYear =
SELECTEDVALUE ( BSC[year] )
VAR CurrentDate =
DATE ( CurrentYear, CurrentMonth, DAY ( EOMONTH ( DATE ( CurrentYear, CurrentMonth, 1 ), 0 ) ) )
RETURN
SUMX (
Team,
VAR StartDate = Team[dateofadmission]
VAR EndDate =
IF (
ISBLANK ( Team[dateoftermination] ),
CurrentDate,
MAX ( CurrentDate, Team[dateoftermination] )
)
RETURN
EndDate - StartDate
)
llo
Try this
Employee calc is my name table
The problem is that, in reality, that information is on 2 separate tables
I just put it like that in the excel to explain what I wanted to do
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
20 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
26 | |
10 | |
10 | |
9 | |
6 |