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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello, I would like to create a calculate column to see the last country by an ID that would be calculated by a versioning.
Here is an example of what I would like to find:
Do you have any idea how to do this in DAX? Thanks in advance!
Solved! Go to Solution.
@Anonymous Try:
Last Country Column =
VAR __ID = [ID]
VAR __VersionMax = MAXX(FILTER('Table',[ID] = __ID),[Version])
VAR __Last = MAXX(FILTER('Table',[ID] = __ID && [Version] = __VersionMax),[Country])
RETURN
__Last
You could add a column like
Last Country =
SELECTCOLUMNS (
CALCULATETABLE (
TOPN ( 1, 'Table', 'Table'[Version] ),
ALLEXCEPT ( 'Table', 'Table'[ID] )
),
"@val", 'Table'[Country]
)
@Anonymous Try:
Last Country Column =
VAR __ID = [ID]
VAR __VersionMax = MAXX(FILTER('Table',[ID] = __ID),[Version])
VAR __Last = MAXX(FILTER('Table',[ID] = __ID && [Version] = __VersionMax),[Country])
RETURN
__Last