Forum Discussion
Issus combining USERELATIONSHIP and FILTER in a measure
- 5 years ago
Hi, Anonymous
You can try this:
If it doesn't work correctly,maybe it’s a behavior of ‘USERELATIONSHIP’,The filter added later still uses the original relationship.If you don't use filter, the 'calculate' function will automatically filter the corresponding data in inactive relationships(date-resolved) based on the current context.
If it doesn’t solve your problem, please feel free to ask me.
Best Regards
Janey Guo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous5 years ago
After additional research and debugging, I was able to come up with the following measure that does exactly what I need. Below is what I changed:
- Removed the "('Issues'[Resolved] <> BLANK()) line since it wasn't adding any value to my results.
- Added "ALL" to my FILTER line
- Added VARs to enable the readability, enable the year and month compare in my IF statement to display values in my line graph up to the current year/month.
VAR FirstShippedDate = CALCULATE(MINX('Issues', 'Issues'[Resolved] ) , ('Issues'[State] = "Shipped" ), ALL ('Issues' ))VAR LastShippedDate = CALCULATE (MAXX('Issues', 'Issues'[Resolved - Copy-yyyy-mm]) ,('Issues'[State] = "Shipped" ), ALL ('Issues' ) )Var MaxCalendarDate = MAXX('Date', 'Date'[Year-Month])ReturnIF ( MaxCalendarDate > LastShippedDate && MaxCalendarDate > TODAY(),BLANK(),CALCULATE( COUNT ( 'Issues'[Resolved] ),('Issues'[State] = "Shipped" ),USERELATIONSHIP ('Date'[Date], 'Issues'[Resolved] ) ,FILTER ( ALL('Date' ), ('Date'[Date] <= MAX('Date'[Date]) ))) )Thanks so much for implying that there were issues with my measure and guiding me to dig deeper. I initially thought that a FILTER statement could not follow a USERELATIONSHIP statement, but that is not the case.
Thanks!!!
| Issue Id | Project | Resolved | State | Upload Date | Case Options |
| CPP11-1 | Project A | 4 Mar 2020 | Canceled | 31 Jan 2020 | Plan + 3DP |
| CPP11-2 | Project A | 10 Mar 2020 | Shipped | 10 Feb 2020 | Plan + 3DP |
| CPP11-4 | Project A | 10 Mar 2020 | Shipped | 27 Feb 2020 | Plan + 3DP |
| CPP11-3 | Project A | 26 May 2020 | Shipped | 24 Feb 2020 | Plan + 3DP |
| CPP11-7 | Project A | 26 May 2020 | Shipped | 11 Mar 2020 | Plan + 3DP |
| CPP11-8 | Project A | 26 May 2020 | Shipped | 13 Mar 2020 | Plan + 3DP |
| CPP11-6 | Project A | 26 May 2020 | Shipped | 4 Mar 2020 | Plan + 3DP |
| CPP11-17 | Project A | 27 May 2020 | Canceled | 13 May 2020 | Plan + 3DP |
| CPP11-19 | Project A | 29 May 2020 | Shipped | 13 May 2020 | Plan + 3DP |
| CPP11-26 | Project A | 5 Jun 2020 | Shipped | 12 May 2020 | Plan + 3DP |
| CPP11-9 | Project A | 10 Jun 2020 | Canceled | 13 Mar 2020 | Plan + 3DP |
| CPP11-16 | Project A | 10 Jun 2020 | Canceled | 13 May 2020 | Plan + 3DP |
| CPP11-12 | Project A | 10 Jun 2020 | Canceled | 27 Apr 2020 | Plan + 3DP |
| CPP11-23 | Project A | 10 Jun 2020 | Shipped | 22 May 2020 | Plan + 3DP |
| CPP11-22 | Project A | 10 Jun 2020 | Shipped | 15 May 2020 | Plan + 3DP |
| CPP11-28 | Project A | 15 Jun 2020 | Shipped | 21 May 2020 | Plan + 3DP |
| CPP11-29 | Project A | 17 Jun 2020 | Shipped | 3 Jun 2020 | Plan + 3DP |
| CPP11-36 | Project A | 19 Jun 2020 | Canceled | 10 Jun 2020 | Plan + 3DP |
| CPP11-33 | Project A | 19 Jun 2020 | Canceled | 6 Jun 2020 | Plan + 3DP |
| CPP11-30 | Project A | 30 Jun 2020 | Shipped | 3 Jun 2020 | Plan + 3DP |
| CPP11-32 | Project A | 9 Jul 2020 | Shipped | 6 Jun 2020 | Plan + 3DP |
| CPP11-35 | Project A | 10 Jul 2020 | Canceled | 10 Jun 2020 | Plan + 3DP |
| CPP11-57 | Project A | 23 Jul 2020 | Shipped | 17 Jun 2020 | Plan + 3DP |
| CPP11-55 | Project A | 23 Jul 2020 | Shipped | 17 Jun 2020 | Plan + 3DP |
| CPP11-111 | Project A | 2 Sep 2020 | Shipped | 11 Aug 2020 | Plan + 3DP |
| CPP11-140 | Project A | 3 Sep 2020 | Canceled | 26 Aug 2020 | Plan + 3DP |
| CPP11-135 | Project A | 3 Sep 2020 | Canceled | 18 Aug 2020 | Plan + 3DP |
| CPP11-190 | Project A | 11 Sep 2020 | Canceled | 10 Sep 2020 | Plan + 3DP |
| CPP11-144 | Project A | 17 Sep 2020 | Shipped | 26 Aug 2020 | Plan + 3DP |
| CPP11-128 | Project A | 17 Sep 2020 | Shipped | 14 Aug 2020 | Plan + 3DP |
| CPP11-136 | Project A | 17 Sep 2020 | Shipped | 19 Aug 2020 | Plan + 3DP |
| CPP11-243 | Project A | 21 Sep 2020 | Canceled | 21 Sep 2020 | Plan + 3DP |
| CPP11-253 | Project A | 22 Sep 2020 | Canceled | 21 Sep 2020 | Plan + 3DP |
| CPP11-252 | Project A | 22 Sep 2020 | Canceled | 21 Sep 2020 | Plan + 3DP |
| CPP11-142 | Project A | 24 Sep 2020 | Shipped | 26 Aug 2020 | Plan + 3DP |
| CPP11-162 | Project A | 24 Sep 2020 | Shipped | 1 Sep 2020 | Plan + 3DP |
| CPP11-143 | Project A | 24 Sep 2020 | Shipped | 26 Aug 2020 | Plan + 3DP |
| CPP11-321 | Project A | Manufacturing Ordered | 15 Nov 2020 | Plan + 3DP | |
| CPP11-334 | Project A | Manufacturing Ordered | 16 Nov 2020 | Plan + 3DP | |
| CPP11-250 | Project A | Review - Mechanical | 21 Sep 2020 | Plan + 3DP | |
| CPP11-337 | Project A | Review - Segmentation | 16 Nov 2020 | Plan + 3DP | |
| CPP11-338 | Project A | Review - Segmentation | 16 Nov 2020 | Plan + 3DP | |
| CPP11-323 | Project A | Submitted | 15 Nov 2020 | Plan + 3DP | |
| CPP11-328 | Project A | Submitted | 16 Nov 2020 | Review Case | |
| CPP11-329 | Project A | Submitted | 16 Nov 2020 | Plan Only | |
| CPP11-332 | Project A | Submitted | 16 Nov 2020 | Plan Only | |
| CPP11-333 | Project A | Submitted | 16 Nov 2020 | Plan + 3DP | |
| CPP11-335 | Project A | Submitted | 16 Nov 2020 | Plan + 3DP | |
| CPP11-339 | Project A | Submitted | No case options |
- Ashish_Mathur5 years ago
Super User
Hi,
I have jumped in late into this post but would still like to help. Based on the sample data that you have shared, coould you clearly show the expected result. I am not concerned with your formulas. Just describe the business question and show me your expected result.