Forum Discussion

Marshmallow's avatar
Marshmallow
Icon for Helper II rankHelper II
1 year ago
Solved

Help with creating double chart line to compare current FY vs prev FY

Hi,

 

I am hoping there is a simple way to do this. Here is sample data.

 

Can someone please help me with the dax script to create double line chart with Month as X-axis and Count (date signed) with condition only count date signed that has: PA, PA1, PA2 on it. Also to hide Oct onwards for year 2025 as there is no data.

 

Then comes next financial year, it will automatically switch graph to show FY25-26 and FY 26-27

 

 

 

Date_signedCondition
1/7/24PA
31/7/24PA1
15/8/24PA2
19/9/24AAA
30/9/24PA1 
10/10/24PA2
12/10/24AAA
13/10/24PA1
12/11/24PA2
7/12/24PA
2/12/24PA1 
3/12/24PA2
4/1/25PA
31/2/25PA1
15/3/25PA2
19/4/25PA
20/5/25PA1 
10/5/25PA2
23/6/25PA
13/7/25PA1
12/7/25PA2
7/8/25PA
2/9/25PA1 
15/9/25PA2

 

 

 

The chart needs to look like:

Hopefully someone able to assist as at the moment i think i have done the inefficient way.

 

  • Hi,

    I assume fiscal year starts every March.

    I tried to create calendar table, and please check the below picture and the attached pbix file if it suits your inquiry.

     

     

    Count: = 
    CALCULATE ( COUNTROWS ( data ), data[Condition] IN { "PA", "PA1", "PA2" } )

     

    current year: = 
    VAR _currentyear =
        YEAR ( CALCULATE ( MAX ( data[Date_signed] ), REMOVEFILTERS () ) )
    VAR _currentfiscalyear =
        MAXX (
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Calendar Year] = _currentyear ),
            'Calendar'[Fiscal Year]
        )
    VAR _count =
        CALCULATE (
            [Count:],
            'Calendar'[Fiscal Year] = _currentfiscalyear
        )
    RETURN
        _count

     

    previous year: = 
    VAR _currentyear =
        YEAR ( CALCULATE ( MAX ( data[Date_signed] ), REMOVEFILTERS () ) )
    VAR _currentfiscalyearsort =
        MAXX (
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Calendar Year] = _currentyear ),
            'Calendar'[Fiscal Year sort]
        )
    VAR _count =
        CALCULATE (
            [Count:],
            'Calendar'[Fiscal Year sort] = _currentfiscalyearsort - 1
        )
    RETURN
        IF ( [current year:], _count )

     

6 Replies

  • Hi,

    I assume fiscal year starts every March.

    I tried to create calendar table, and please check the below picture and the attached pbix file if it suits your inquiry.

     

     

    Count: = 
    CALCULATE ( COUNTROWS ( data ), data[Condition] IN { "PA", "PA1", "PA2" } )

     

    current year: = 
    VAR _currentyear =
        YEAR ( CALCULATE ( MAX ( data[Date_signed] ), REMOVEFILTERS () ) )
    VAR _currentfiscalyear =
        MAXX (
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Calendar Year] = _currentyear ),
            'Calendar'[Fiscal Year]
        )
    VAR _count =
        CALCULATE (
            [Count:],
            'Calendar'[Fiscal Year] = _currentfiscalyear
        )
    RETURN
        _count

     

    previous year: = 
    VAR _currentyear =
        YEAR ( CALCULATE ( MAX ( data[Date_signed] ), REMOVEFILTERS () ) )
    VAR _currentfiscalyearsort =
        MAXX (
            FILTER ( ALL ( 'Calendar' ), 'Calendar'[Calendar Year] = _currentyear ),
            'Calendar'[Fiscal Year sort]
        )
    VAR _count =
        CALCULATE (
            [Count:],
            'Calendar'[Fiscal Year sort] = _currentfiscalyearsort - 1
        )
    RETURN
        IF ( [current year:], _count )

     

  • Irwan's avatar
    Irwan
    Icon for Super User rankSuper User

    hello   

    i would do like this (not sure if this same as yours).

     

    create two measures for Current FY and Prev FY with following DAX

    Current FY =
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table',
            YEAR('Table'[Date_signed])=YEAR(TODAY())&&
            ('Table'[Condition]="PA"||'Table'[Condition]="PA1"||'Table'[Condition]="PA2")
        )
    )
    Prev FY =
    CALCULATE(
        COUNTROWS('Table'),
        FILTER(
            'Table',
            YEAR('Table'[Date_signed])=YEAR(TODAY())-1&&
            ('Table'[Condition]="PA"||'Table'[Condition]="PA1"||'Table'[Condition]="PA2")
        )
    )
    then create another measure for display (seems you want to show when both have value).
    Show =
    IF(
        ISBLANK([Prev FY])||ISBLANK([Current FY]),
        0,
        1
    )
      

     

    Hope this will help.

    Thank you.

    Marshmallow

    • Marshmallow's avatar
      Marshmallow
      Icon for Helper II rankHelper II

      Where is the months post Sept? It needs to be displayed too as 2024 has data in it.