Forum Discussion
TonyGu
Helper I
4 years agoDAX Column
I would like to have the Define column return 1, if ID only appear 1 time in that year. If that ID appear twice or more, return 1 for the earliest Month, and 0 for the rest month. Below is the result...
- 4 years ago
You can just check if the month is the first one that year or not.
Try this as a calculated column:
Define = VAR _FirstMonth = CALCULATE ( MIN ( Table1[MONTH] ), ALLEXCEPT ( Table1, Table1[ID], Table1[YEAR] ) ) RETURN IF ( Table1[MONTH] = _FirstMonth, 1, 0 )
Greg_Deckler
Community Champion
4 years agoTonyGu Maybe:
Define =
VAR __ID = [ID]
VAR __Year = [Year]
VAR __Month = [Month]
VAR __MinMonth = MINX(FILTER('Table',[ID] = __ID && [Year] = __Year),[Month])
VAR __Table = SUMMARIZECOLUMNS('Table'[ID],'Table'[Year],"__Count",COUNTROWS('Table'))
RETURN
SWITCH(TRUE(),
COUNTROWS(FILTER(__Table,[ID] = __ID && [Year] = __Year)) = 1,1,
__Month = __MinMonth, 1,
0
)