Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I ahve table that has 3 columns:
Date - Range from 2020 to 2021
Name - name that repeats occasionaly
Type - contains flag if the name is new or repeated
Here is the example:
Name | Date | Type |
Smith | 1/1/2020 | Repeat |
Johnson | 1/2/2020 | Repeat |
Williams | 1/3/2020 | Repeat |
Brown | 1/4/2020 | Repeat |
Jones | 1/5/2020 | Repeat |
Garcia | 1/6/2020 | Repeat |
Miller | 1/7/2020 | Repeat |
Davis | 1/8/2020 | Repeat |
Rodriguez | 1/9/2020 | Repeat |
Martinez | 1/10/2020 | Repeat |
Smith | 1/11/2020 | Repeat |
Johnson | 1/12/2020 | Repeat |
Williams | 1/13/2020 | Repeat |
Brown | 1/14/2020 | Repeat |
Jones | 1/15/2020 | Repeat |
Garcia | 1/16/2020 | Repeat |
Miller | 1/17/2020 | Repeat |
Davis | 1/18/2020 | Repeat |
Rodriguez | 1/19/2020 | Repeat |
Martinez | 1/20/2020 | Repeat |
Smith | 1/21/2020 | Repeat |
Johnson | 1/22/2020 | Repeat |
Williams | 1/23/2020 | Repeat |
Brown | 1/24/2020 | Repeat |
Jones | 1/25/2020 | Repeat |
Garcia | 1/26/2020 | Repeat |
Miller | 1/27/2020 | Repeat |
Davis | 1/28/2020 | Repeat |
Rodriguez | 1/29/2020 | Repeat |
Martinez | 1/30/2020 | Repeat |
Smith | 1/31/2020 | Repeat |
Johnson | 2/1/2020 | Repeat |
Williams | 2/2/2020 | Repeat |
Brown | 2/3/2020 | Repeat |
Jones | 2/4/2020 | Repeat |
Garcia | 2/5/2020 | Repeat |
Miller | 2/6/2020 | Repeat |
Davis | 2/7/2020 | Repeat |
Rodriguez | 2/8/2020 | Repeat |
Martinez | 2/9/2020 | Repeat |
Sandroni | 2/10/2020 | New |
Smith | 2/11/2020 | Repeat |
Johnson | 2/12/2020 | Repeat |
Williams | 2/13/2020 | Repeat |
Brown | 2/14/2020 | Repeat |
Jones | 2/15/2020 | Repeat |
Garcia | 2/16/2020 | Repeat |
Miller | 2/17/2020 | Repeat |
Davis | 2/18/2020 | Repeat |
Rodriguez | 2/19/2020 | Repeat |
Martinez | 2/20/2020 | Repeat |
Sandroni | 2/21/2020 | Repeat |
Smith | 2/22/2020 | Repeat |
Johnson | 2/23/2020 | Repeat |
Williams | 2/24/2020 | Repeat |
Brown | 2/25/2020 | Repeat |
Jones | 2/26/2020 | Repeat |
Garcia | 2/27/2020 | Repeat |
Miller | 2/28/2020 | Repeat |
Davis | 2/29/2020 | Repeat |
Rodriguez | 3/1/2020 | Repeat |
Martinez | 3/2/2020 | Repeat |
Smith | 3/3/2020 | Repeat |
What i need is to add one more colum Exclude that will contain yes value that is set only if there was a new name in the month but on it second, 3rd, 4th... occurance.
For example name Sandroni is apearing first time in February but also it apears second time in February. Next to the first occurance of that name it should be blank but next to the second occurance of that name within same month should say Yes.
Something like this:
Name | Date | Type | Exclude |
Smith | 1/1/2020 | Repeat | |
Johnson | 1/2/2020 | Repeat | |
Williams | 1/3/2020 | Repeat | |
Brown | 1/4/2020 | Repeat | |
Jones | 1/5/2020 | Repeat | |
Garcia | 1/6/2020 | Repeat | |
Miller | 1/7/2020 | Repeat | |
Davis | 1/8/2020 | Repeat | |
Rodriguez | 1/9/2020 | Repeat | |
Martinez | 1/10/2020 | Repeat | |
Smith | 1/11/2020 | Repeat | |
Johnson | 1/12/2020 | Repeat | |
Williams | 1/13/2020 | Repeat | |
Brown | 1/14/2020 | Repeat | |
Jones | 1/15/2020 | Repeat | |
Garcia | 1/16/2020 | Repeat | |
Miller | 1/17/2020 | Repeat | |
Davis | 1/18/2020 | Repeat | |
Rodriguez | 1/19/2020 | Repeat | |
Martinez | 1/20/2020 | Repeat | |
Smith | 1/21/2020 | Repeat | |
Johnson | 1/22/2020 | Repeat | |
Williams | 1/23/2020 | Repeat | |
Brown | 1/24/2020 | Repeat | |
Jones | 1/25/2020 | Repeat | |
Garcia | 1/26/2020 | Repeat | |
Miller | 1/27/2020 | Repeat | |
Davis | 1/28/2020 | Repeat | |
Rodriguez | 1/29/2020 | Repeat | |
Martinez | 1/30/2020 | Repeat | |
Smith | 1/31/2020 | Repeat | |
Johnson | 2/1/2020 | Repeat | |
Williams | 2/2/2020 | Repeat | |
Brown | 2/3/2020 | Repeat | |
Jones | 2/4/2020 | Repeat | |
Garcia | 2/5/2020 | Repeat | |
Miller | 2/6/2020 | Repeat | |
Davis | 2/7/2020 | Repeat | |
Rodriguez | 2/8/2020 | Repeat | |
Martinez | 2/9/2020 | Repeat | |
Sandroni | 2/10/2020 | New | No |
Smith | 2/11/2020 | Repeat | |
Johnson | 2/12/2020 | Repeat | |
Williams | 2/13/2020 | Repeat | |
Brown | 2/14/2020 | Repeat | |
Jones | 2/15/2020 | Repeat | |
Garcia | 2/16/2020 | Repeat | |
Miller | 2/17/2020 | Repeat | |
Davis | 2/18/2020 | Repeat | |
Rodriguez | 2/19/2020 | Repeat | |
Martinez | 2/20/2020 | Repeat | |
Sandroni | 2/21/2020 | Repeat | Yes |
Smith | 2/22/2020 | Repeat | |
Johnson | 2/23/2020 | Repeat | |
Williams | 2/24/2020 | Repeat | |
Brown | 2/25/2020 | Repeat | |
Jones | 2/26/2020 | Repeat | |
Garcia | 2/27/2020 | Repeat | |
Miller | 2/28/2020 | Repeat | |
Davis | 2/29/2020 | Repeat | |
Rodriguez | 3/1/2020 | Repeat | |
Martinez | 3/2/2020 | Repeat | |
Smith | 3/3/2020 | Repeat |
How would i do this?
Solved! Go to Solution.
Hi @slav84 ,
According to your description, I'd suggest you create a Rank variable and then based on it to set Blank and Yes or something else:
Exclude =
VAR _rankbymonth =
RANKX (
FILTER (
'Table',
[Name] = EARLIER ( 'Table'[Name] )
&& YEAR ( [Date] ) = EARLIER ( 'Table'[Date].[Year] )
&& MONTH ( [Date] ) = EARLIER ( 'Table'[Date].[MonthNo] )
),
[Date],
,
ASC,
DENSE
)
VAR _rankbyall =
RANKX (
FILTER ( 'Table', [Name] = EARLIER ( 'Table'[Name] ) ),
[Date],
,
ASC,
DENSE
)
RETURN
IF (
YEAR ( [Date] ) = MINX ( ALL ( 'Table' ), [Date].[Year] )
&& MONTH ( [Date] ) = MINX ( ALL ( 'Table' ), [Date].[MonthNo] ),
BLANK (),
IF (
_rankbyall = 1
&& _rankbyall = _rankbymonth,
"No",
IF ( _rankbymonth = 2 && _rankbyall = _rankbymonth, "Yes" )
)
)
Here is the final output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @slav84 ,
According to your description, I'd suggest you create a Rank variable and then based on it to set Blank and Yes or something else:
Exclude =
VAR _rankbymonth =
RANKX (
FILTER (
'Table',
[Name] = EARLIER ( 'Table'[Name] )
&& YEAR ( [Date] ) = EARLIER ( 'Table'[Date].[Year] )
&& MONTH ( [Date] ) = EARLIER ( 'Table'[Date].[MonthNo] )
),
[Date],
,
ASC,
DENSE
)
VAR _rankbyall =
RANKX (
FILTER ( 'Table', [Name] = EARLIER ( 'Table'[Name] ) ),
[Date],
,
ASC,
DENSE
)
RETURN
IF (
YEAR ( [Date] ) = MINX ( ALL ( 'Table' ), [Date].[Year] )
&& MONTH ( [Date] ) = MINX ( ALL ( 'Table' ), [Date].[MonthNo] ),
BLANK (),
IF (
_rankbyall = 1
&& _rankbyall = _rankbymonth,
"No",
IF ( _rankbymonth = 2 && _rankbyall = _rankbymonth, "Yes" )
)
)
Here is the final output:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@slav84 , Create a new column like
new column=
var _month = eomonth([date])
var _min = minx(filter(table, [Name] =earlier([Name]) && eomonth([date]) = _month), [Date])
return
if( [Date] =_min, "No" , "Yes")
User | Count |
---|---|
93 | |
83 | |
77 | |
71 | |
65 |
User | Count |
---|---|
114 | |
101 | |
96 | |
65 | |
60 |