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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
M_SBS_6
Helper V
Helper V

Financial Year Quarter

Hi, 

I need to create a Quarter Variable based on a month_start_no variable and a date_app_start if possible, please

 

I have several different financials years: which I think makes it more difficult:

Jan - Dec (Jan, Feb, Mar (Q1) Apr, May, Jun (Q2) Jul, Aug, Sep (Q3) Oct, Nov, Dec (Q4)

Mar - Feb (Mar, Apr, May (Q1) Jun, Jul, Aug (Q2), Sep, Oct, Nov (Q3) Dec, Jan, Feb (Q4)

Apr - Mar (Apr, May, Jun (Q1) Jul, Aug, Sep (Q2) Oct, Nov, Dec (Q3) Jan, Feb, Mar (Q4)

July - June (July, Aug, Sep (Q1) Oct, Nov, Dec (Q2) Jan, Feb, Mar (Q3) Apr, May, Jun (Q4)

Oct - Sept (Oct, Nov, Dec (Q1) Jan, Feb, Mar (Q2), Apr, May, Jun (Q3) July, Aug, Sep (Q4)

 

So I need somthing that will say, as an example - if month_start_no = 7 and date_app_start = 01/08/2022 then Q1

 

I have attached sample output that I hope to achieve.

 

app_date_startmonth_nameQuarter
05/07/20227Q1
12/12/20227Q2
03/01/20237Q3
17/01/20037Q3
19/03/20237Q3
30/06/20237Q4
05/07/20224Q2
12/12/20224Q3
03/01/20234Q3
17/01/20034Q4
19/03/20234Q4
05/07/20221Q3
12/12/20221Q4
03/01/202310Q2
17/01/200310Q2
19/03/202310Q2
01/04/202210Q3
07/09/20223Q3
01/01/20233Q4
25/02/20233Q4
26/02/20233Q4

 

1 ACCEPTED SOLUTION
v-yinliw-msft
Community Support
Community Support

Hi @M_SBS_6 ,

 

And there is another mothed to solve this question:

New a table:

 

Financials =
DISTINCT (
    CROSSJOIN (
        SELECTCOLUMNS ( { 1, 3, 4, 7, 10 }, "Financial Start Month", [Value] ),
        SELECTCOLUMNS (
            CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2022, 12, 1 ) ),
            "MonthName", FORMAT ( [Date], "mmm" ),
            "MonthNumber", MONTH ( [Date] )
        )
    )
)

 

 

Then new a column to the new table:

 

Financial Quarter =
"Q"
    & SWITCH (
        [Financial Start Month],
        1, QUARTER ( CONVERT ( [MonthName] & " 1", DATETIME ) ),
        3,
            VAR m1 = [MonthNumber] - 2
            RETURN
                QUARTER ( DATE ( 2022, IF ( m1 <= 0, m1 + 12, m1 ), 1 ) ),
        4,
            VAR m2 = [MonthNumber] - 3
            RETURN
                QUARTER ( DATE ( 2022, IF ( m2 <= 0, m2 + 12, m2 ), 1 ) ),
        7,
            VAR m3 = [MonthNumber] - 6
            RETURN
                QUARTER ( DATE ( 2022, IF ( m3 <= 0, m3 + 12, m3 ), 1 ) ),
        10,
            VAR m4 = [MonthNumber] - 9
            RETURN
                QUARTER ( DATE ( 2022, IF ( m4 <= 0, m4 + 12, m4 ), 1 ) )
    )

 

 

Then in the original table, please add the column:

 

Quarter =
LOOKUPVALUE (
    'Financials'[Financial Quarter],
    Financials[Financial Start Month], [month_name],
    Financials[MonthNumber], MONTH ( [app_date_start] )
)

 

 

The result is:

vyinliwmsft_0-1668141511550.png

 

Hope this helps you. Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yinliw-msft
Community Support
Community Support

Hi @M_SBS_6 ,

 

And there is another mothed to solve this question:

New a table:

 

Financials =
DISTINCT (
    CROSSJOIN (
        SELECTCOLUMNS ( { 1, 3, 4, 7, 10 }, "Financial Start Month", [Value] ),
        SELECTCOLUMNS (
            CALENDAR ( DATE ( 2022, 1, 1 ), DATE ( 2022, 12, 1 ) ),
            "MonthName", FORMAT ( [Date], "mmm" ),
            "MonthNumber", MONTH ( [Date] )
        )
    )
)

 

 

Then new a column to the new table:

 

Financial Quarter =
"Q"
    & SWITCH (
        [Financial Start Month],
        1, QUARTER ( CONVERT ( [MonthName] & " 1", DATETIME ) ),
        3,
            VAR m1 = [MonthNumber] - 2
            RETURN
                QUARTER ( DATE ( 2022, IF ( m1 <= 0, m1 + 12, m1 ), 1 ) ),
        4,
            VAR m2 = [MonthNumber] - 3
            RETURN
                QUARTER ( DATE ( 2022, IF ( m2 <= 0, m2 + 12, m2 ), 1 ) ),
        7,
            VAR m3 = [MonthNumber] - 6
            RETURN
                QUARTER ( DATE ( 2022, IF ( m3 <= 0, m3 + 12, m3 ), 1 ) ),
        10,
            VAR m4 = [MonthNumber] - 9
            RETURN
                QUARTER ( DATE ( 2022, IF ( m4 <= 0, m4 + 12, m4 ), 1 ) )
    )

 

 

Then in the original table, please add the column:

 

Quarter =
LOOKUPVALUE (
    'Financials'[Financial Quarter],
    Financials[Financial Start Month], [month_name],
    Financials[MonthNumber], MONTH ( [app_date_start] )
)

 

 

The result is:

vyinliwmsft_0-1668141511550.png

 

Hope this helps you. Here is my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

v-yinliw-msft
Community Support
Community Support

Hi @M_SBS_6 ,

 

You can try this method:

I create some new tables:

vyinliwmsft_0-1668129966291.png

 

Use JAN as an example:

vyinliwmsft_1-1668129966292.png

 

And I create 5 tables to select the first row.

vyinliwmsft_2-1668129966293.png

 

The JAN and the TopJAN is an example that other tables are the same.

Then create a new column in the table:

Month = MONTH('Table'[app_date_start])

Then create Quarter column:

Quarter =

IF (

    'Table'[month_name] = MAX ( 'TopJAN'[Jan-Dec] ),

    CALCULATE (

        MAX ( 'JAN'[Quarter] ),

        FILTER ( 'JAN', 'Table'[Month] = 'JAN'[Month] )

    ),

    IF (

        'Table'[month_name] = MAX ( 'TopMAR'[Mar-Feb] ),

        CALCULATE (

            MAX ( 'MAR'[Quarter] ),

            FILTER ( 'MAR', 'Table'[Month] = 'MAR'[Month] )

        ),

        IF (

            'Table'[month_name] = MAX ( 'TopAPR'[Apr-Mar] ),

            CALCULATE (

                MAX ( 'APR'[Quarter] ),

                FILTER ( 'APR', 'Table'[Month] = 'APR'[Month] )

            ),

            IF (

                'Table'[month_name] = MAX ( 'TopJUL'[Jul-Jun] ),

                CALCULATE (

                    MAX ( 'JUL'[Quarter] ),

                    FILTER ( 'JUL', 'Table'[Month] = 'JUL'[Month] )

                ),

                IF (

                    'Table'[month_name] = MAX ( 'TopOCT'[Oct-Sep] ),

                    CALCULATE (

                        MAX ( 'OCT'[Quarter] ),

                        FILTER ( 'OCT', 'Table'[Month] = 'OCT'[Month] )

                    )

                )

            )

        )

    )

)

 

The result is:

vyinliwmsft_3-1668129966295.png

 

 

Hope this helps you. Here is my PBIX file.

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@M_SBS_6 , refer my blog can help

Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calend...
https://medium.com/chandakamit/cheat-sheet-calendar-of-any-standard-month-just-one-variable-apart-5e...
https://amitchandak.medium.com/cheat-sheet-power-query-financial-year-calendar-5ceaacb520f1

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.