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

Index and year_month

Hi-- I would like to create (in the desktop version) a table call "Date" with unique YearMonth field and an index. Like that:

 

Index:     Year_Date:

1               2013/01

2               2013/02

3               2013/04

4               2013/05

 

 

Starting in 2013/01 and finishing 2025/12

 

How do I do that ?

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Index and year_month

@SRK_23

 

Using Query Editor/ Power Query

 

Create a Blank Query>>Go to Advanced Editor and copy paste this

 

let
    Source = {2013..2025},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each {1..12}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Year_Date", each Text.From([Column1])&"-"&Text.End("0"&Text.From([Custom]),2)),
    #"Renamed Columns" = Table.RenameColumns(#"Added Custom1",{{"Column1", "Year"}, {"Custom", "Months"}}),
    #"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1)
in
    #"Added Index"

 

 

Try my new Power BI game Cross the River

View solution in original post

2 REPLIES 2
Highlighted
Super User I
Super User I

Re: Index and year_month

@SRK_23 Please create a "New Table" as below

 

Test141DateGen = 
VAR _Index = SELECTCOLUMNS(GENERATESERIES(1,12),"Index",[Value])
VAR _Date = SELECTCOLUMNS(GENERATESERIES(2013,2025),"Year",[Value])
RETURN CROSSJOIN(_Index,_Date)

Then, two new fields which will be final output as expected

 

YYYY/MM = Test141DateGen[Year] & "/" & IF(LEN(Test141DateGen[Index])=1,"0"&Test141DateGen[Index],Test141DateGen[Index])
IndexFinal = RANK.EQ(Test141DateGen[YYYY/MM],Test141DateGen[YYYY/MM],ASC)

image.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Super User III
Super User III

Re: Index and year_month

@SRK_23

 

Using Query Editor/ Power Query

 

Create a Blank Query>>Go to Advanced Editor and copy paste this

 

let
    Source = {2013..2025},
    #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each {1..12}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Year_Date", each Text.From([Column1])&"-"&Text.End("0"&Text.From([Custom]),2)),
    #"Renamed Columns" = Table.RenameColumns(#"Added Custom1",{{"Column1", "Year"}, {"Custom", "Months"}}),
    #"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1)
in
    #"Added Index"

 

 

Try my new Power BI game Cross the River

View solution in original post

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors