Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I need to get movement in our roster and need to pull in the prior months cost center name in a calculcated column
This is what my data looks like
Date EMPID Cost Center Name
2/29/2020 001 Executive
2/29/2020 002 Apps
1/31/2020 001 Apps
1/31/2020 002 Apps
Ideally the prior cost center column would show Apps for Emp 001 for 2/29/2020
I've tried Calculate(Values(Cost Center Name),Filter(Table,EMPID=Earlier(EMPID)),DATEADD(Date Table(Date,-1,Month))
This returns that there is a circular dependency.
Thank you in advance for the help.
Solved! Go to Solution.
Perhaps:
Column =
VAR __PreviousDate = MAXX(FILTER('Table',[Date]<EARLIER([Date])&&[EMPID]=EARLIER([EMPID])),[Date])
RETURN
MAXX(FILTER('Table',[EMPID]=EARLIER([EMPID]) && [Date]=__PreviousDate),[Cost Center Name])
Hi , @cmilligan262
Here is a demo.
Try to change your measure as below:
The prior cost center column =
VAR d = [Date]
RETURN
CALCULATE (
MAX ( 'Table'[Cost Center Name] ),
FILTER (
'Table',
'Table'[EMPID] = EARLIER ( 'Table'[EMPID] )
&& 'Table'[Date]
>= DATE ( YEAR ( d ), MONTH ( d ) - 1, 1 )
&& 'Table'[Date]
<= DATE ( YEAR ( d ), MONTH ( d ), 1 ) - 1
)
)
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.
Perhaps:
Column =
VAR __PreviousDate = MAXX(FILTER('Table',[Date]<EARLIER([Date])&&[EMPID]=EARLIER([EMPID])),[Date])
RETURN
MAXX(FILTER('Table',[EMPID]=EARLIER([EMPID]) && [Date]=__PreviousDate),[Cost Center Name])
Thank you @Greg_Deckler that worked.
Do you have any explanation on why that would work and why I was getting a circular dependecy error on the formula I tried
I believe the short answer is that you were using CACULATE in a column formula along with DISTINCT or VALUES and that tends to be bad. @edhans probably has a much deeper and more insightful explanation as I have seen a really great explanation in a separate thread. @edhans would highly recommend making that a blog article.
Hi @cmilligan262 ,
Try this code to create a calculated column:
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 47 | |
| 44 | |
| 40 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 70 | |
| 68 | |
| 32 | |
| 27 | |
| 25 |