Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
OscarSuarez10
Helper III
Helper III

Repeated Index Per Year

Hi, I want to make an Index for an object that is repeated in some periods like in the following table but I don´t know how

 

YEAROBJECTOUTPUT INDEX
1990A1
1991A2
1992A3
1990B1
1991B2
1992B3
1990C1
1991C2
1992C3
1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @OscarSuarez10 ,

 

Or we can create an index column by DAX like this.

 

index = RANKX(VALUES(Query1[YEAR]),Query1[YEAR],,ASC,Dense)

Capture.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @OscarSuarez10 ,

 

Or we can create an index column by DAX like this.

 

index = RANKX(VALUES(Query1[YEAR]),Query1[YEAR],,ASC,Dense)

Capture.PNG

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Take a look at the code below, but basically you Groupy Object and aggregate by All Rows. Then add an index column to that aggregated Table. 

Table.AddIndexColumn([All Data], "Object", 1,1)

Then remove the other columns and expand out

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrS0NFDSUXJUitUBcwyROUbIHJAyJ2RlTsjKnJCVOSMrc0ZWBuTEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [YEAR = _t, OBJECT = _t]),
    #"Grouped Rows" = Table.Group(Source, {"OBJECT"}, {{"All Data", each _, type table [YEAR=number, OBJECT=text, OUTPUT INDEX=number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([All Data], "Object", 1,1)),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"YEAR", "OBJECT", "Object"}, {"YEAR", "OBJECT.1", "Object"})
in
    #"Expanded Custom"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors