Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello Forum,
TIA for reading and responding, I am using SSAS as a source, and have created this measure to calculate month difference between 2 dates
New Hires Month Datediff =
IF (
MAX('MovementSnapshot'[AppointmentDateKey]) <> BLANK ()
&& MAX('MovementSnapshot'[AppointmentDateKey]) <> -1,
VAR CurrentMovement =
MAX ( 'MovementSnapshot'[AppointmentDateKey] )
VAR CurrentPeriod =
MAX ( 'Period'[YearMonth] )
VAR MovementYear =
VALUE ( LEFT ( CurrentMovement, 4 ) )
VAR MovementMonth =
VALUE ( MID ( CurrentMovement, 5, 2 ) )
VAR PeriodYear =
VALUE ( LEFT ( CurrentPeriod, 4 ) )
VAR PeriodMonth =
VALUE ( RIGHT ( CurrentPeriod, 2 ) )
RETURN
( PeriodYear - MovementYear ) * 12 + PeriodMonth - MovementMonth
)
The issue comes when I am trying to count the number of 0 and 1 month occurrences.
CountNewHires =
COUNTROWS(
FILTER(
SUMMARIZE(
'Period',
'Period'[Yearmonth],
RelatedTable(''MovementSnapshot'[AppointmentDateKey]),
"Value" , [New Hires Month Datediff]
),
[Value] = 0 || [Value] = 1
))
The syntax error is attached.
Solved! Go to Solution.
Hi @Durbslaw
please use the following
New Hires Month Datediff =
VAR CurrentMovement =
MAX ( 'MovementSnapshot'[AppointmentDateKey] )
RETURN
IF (
CurrentMovement <> BLANK ()
&& CurrentMovement <> -1,
VAR CurrentPeriod =
MAX ( 'Period'[YearMonth] )
VAR MovementYear =
VALUE ( LEFT ( CurrentMovement, 4 ) )
VAR MovementMonth =
VALUE ( MID ( CurrentMovement, 5, 2 ) )
VAR PeriodYear =
VALUE ( LEFT ( CurrentPeriod, 4 ) )
VAR PeriodMonth =
VALUE ( RIGHT ( CurrentPeriod, 2 ) )
RETURN
( PeriodYear - MovementYear ) * 12 + PeriodMonth - MovementMonth
)
CountNewHires =
COUNTROWS (
FILTER (
ADDCOLUMNS (
SUMMARIZE ( 'MovementSnapshot', 'Period'[Yearmonth] ),
"Value", [New Hires Month Datediff]
),
[Value] = 0
|| [Value] = 1
)
)
@Durbslaw
I think this is the time when you need to add some columns and create a relatioship between the two tables.
Hi @Durbslaw
please use the following
New Hires Month Datediff =
VAR CurrentMovement =
MAX ( 'MovementSnapshot'[AppointmentDateKey] )
RETURN
IF (
CurrentMovement <> BLANK ()
&& CurrentMovement <> -1,
VAR CurrentPeriod =
MAX ( 'Period'[YearMonth] )
VAR MovementYear =
VALUE ( LEFT ( CurrentMovement, 4 ) )
VAR MovementMonth =
VALUE ( MID ( CurrentMovement, 5, 2 ) )
VAR PeriodYear =
VALUE ( LEFT ( CurrentPeriod, 4 ) )
VAR PeriodMonth =
VALUE ( RIGHT ( CurrentPeriod, 2 ) )
RETURN
( PeriodYear - MovementYear ) * 12 + PeriodMonth - MovementMonth
)
CountNewHires =
COUNTROWS (
FILTER (
ADDCOLUMNS (
SUMMARIZE ( 'MovementSnapshot', 'Period'[Yearmonth] ),
"Value", [New Hires Month Datediff]
),
[Value] = 0
|| [Value] = 1
)
)
@Durbslaw
I think this is the time when you need to add some columns and create a relatioship between the two tables.
I have also tried...
CountNewHires =
COUNTROWS(
FILTER(
SUMMARIZE(
'Period',
'Period'[Yearmonth],
'MovementSnapshot'[AppointmentDateKey],
CALCULATETABLE ( VALUES ('Staff Management' [New Hires Month Datediff] ) )
),
[Value] = 0 || [Value] = 1
))
AND
CountNewHires =
COUNTROWS(
FILTER(
SUMMARIZE(
'Period',
'Period'[Yearmonth],
CALCULATETABLE ('MovementSnapshot'[AppointmentDateKey],
Value , [New Hires Month Datediff]
),
[Value] = 0 || [Value] = 1
))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
104 | |
75 | |
43 | |
39 | |
31 |
User | Count |
---|---|
166 | |
90 | |
65 | |
46 | |
43 |