cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

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

Accepted Solutions
Community Support Team
Community Support Team

Re: Repeated Index Per Year

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 other members find it more quickly.
2 REPLIES 2
Super User
Super User

Re: Repeated Index Per Year

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"
Community Support Team
Community Support Team

Re: Repeated Index Per Year

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 other members find it more quickly.

Helpful resources

Announcements
Back to School Contest

Back to School Contest

Engage and empower students with Power BI!

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Summit Australia 2019

Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

PBI Community Highlights

PBI Community Highlights

Check out what's new in the Power BI Community!

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 85 members 1,499 guests
Please welcome our newest community members: