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
Anonymous
Not applicable

Two columns for months and sequence passed months

Hi guys,

 

I want to create a table of two columns.

 

First colum contains numbers from 1 to 12. These are months of the fiscal year, fiscal year starts from month 10 to month 9

 

second column is for sequence of passed months like shown below in the table:

 

First month is 10 and passed months is 10

Second month is 11 and passed months are 10 and 11

And so on ....

 

Reda89_0-1664201946537.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

It is possible. There could be other ways but this is all I've got to work so far. 

 

Month Table = 
ADDCOLUMNS (
    GENERATESERIES ( 1, 78 ),
    "Month",
        MOD ( FLOOR ( POWER ( 2 * [Value], 1 / 2 ) + 1 / 2 + 8, 1 ), 12 ) + 1,
    "Sequence Passed Months",
        VAR m = floor((sqrt(8*[Value]+1) - 1) / 2, 1)
        RETURN
        MOD ( [Value] - m*(m+1)/2 + 1 + 8 , 12 ) + 1
)

 

Have a check but that should give you what you're after. You can either delete or hide the 'Value' column afterwards.

 

AntonioM_0-1664372958519.png

 

AntonioM_1-1664373058009.png

 

 Hope that helps

View solution in original post

4 REPLIES 4
AntonioM
Solution Sage
Solution Sage

Hi @Anonymous ,

 

You could do this in Power Query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMgKTxmDSBEyagkkzMGkOJi3ApCWYNDSAUBDdhkDtsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Numbers(10, Number.Mod([Column1]+2,12)+1)),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
    #"Calculated Modulo" = Table.TransformColumns(#"Expanded Custom", {{"Custom", each Number.Mod(_-1, 12)+1, type number}})
in
    #"Calculated Modulo"

 

The first two steps are just to create the list of numbers 1-12, you could skip those if you have that already.

 

 

Just curious, what is it you need this for? It could be something you can use time inteligence and DATESYTD for.

Anonymous
Not applicable

Is it possible to do this in dax ?

 

I am trying to use the first column for month selector. The idea is whenever a month is selected from the first column the visual should show data from october (start of the fiscal year) up to selected month.

Alternatively you could just use 'enter data'. It's a bit of typing or you could create and copy it from excel easily enough.

AntonioM_1-1664438128850.png

 

AntonioM_0-1664438122375.png

 

Hi @Anonymous 

 

It is possible. There could be other ways but this is all I've got to work so far. 

 

Month Table = 
ADDCOLUMNS (
    GENERATESERIES ( 1, 78 ),
    "Month",
        MOD ( FLOOR ( POWER ( 2 * [Value], 1 / 2 ) + 1 / 2 + 8, 1 ), 12 ) + 1,
    "Sequence Passed Months",
        VAR m = floor((sqrt(8*[Value]+1) - 1) / 2, 1)
        RETURN
        MOD ( [Value] - m*(m+1)/2 + 1 + 8 , 12 ) + 1
)

 

Have a check but that should give you what you're after. You can either delete or hide the 'Value' column afterwards.

 

AntonioM_0-1664372958519.png

 

AntonioM_1-1664373058009.png

 

 Hope that helps

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