Forum Discussion
Anonymous
4 years agoNot applicable
Unique value Index (duplicates are same)
How would I create a unique value index with Dax code? I am in the process of creating a ragged heirachy using a Tabular model so it has to be done using DAX code (I can't use PQ, etc). What I am loo...
- 4 years ago
Anonymous It seems simpler to me like this:
Index Column = RANKX ( Table, Table[Item],, ASC, DENSE )
Try it!
B.
Greg_Deckler
Community Champion
4 years agoAnonymous Indexes in DAX are not particularly easy and were once thought impossible. Hard to guarantee any sort of sort order, not that I see what sort order you would want. You can try this:
Column =
VAR __Item = [Item]
VAR __Text = CONCATENATEX('Table',[Item],"|")
VAR __Count = PATHLENGTH(__Text)
VAR __Table =
ADDCOLUMNS(
GENERATESERIES(1,__Count,1),
"__Item",PATHITEM(__Text,[Value])
)
VAR __TableFinal =
SUMMARIZE(__Table,[__Item],"Index",MINX(FILTER(__Table,[__Item]=EARLIER([__Item])),[Value]))
RETURN
MINX(FILTER(__TableFinal,[__Item] = __Item),[Index])
Original concept is from The Mythical DAX Index: (2) The Mythical DAX Index - Microsoft Power BI Community