Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
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 I want to get. Not sure if it is doable.
Solved! Go to Solution.
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 )
Hi @TonyGu
Have you solved this question with the help of enthusiastic users? If you have solved the question, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.
If you need more help, please let me know.
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hello:
Give this a try. Hope it helps..
You seem to be assuming that January is always the first month for each year with multiple rows in the Data table (e.g. this would not work if the first D row in the given example were deleted).
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 )
@TonyGu 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
)