Forum Discussion

Rajendrabobade's avatar
5 years ago
Solved

Dynamic column name when selecting filter

Hi ,

I need help ,  whne i select filter on year then my column header name sholud be same as filter selection.

 

eg:I am creating volume measure calculated column  for curret year and previous year , whnever i am select year my column name need to automtically chnage as selcetd in filter.

when i select year filter -FY 20 need same as below , i want same for other year selction as well .

if i slecet FY 19 then prvious year column name change automtically to FY 18.

 

 

category typeFY 19 FY 20 
 previous yearcurrnt year
A3344
B4564655

 

 

 

 

 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Rajendrabobade ,

     

    1.My sample data is this.

    DateSalescategory type

    1/1/20201A
    5/5/20202A
    3/3/20203A
    4/4/20206A
    6/6/20205A
    5/7/20194A
    4/6/20191A
    7/7/20192A
    1/1/20193A
    7/7/20186A
    5/5/20184A
    9/9/20188A
    7/7/20187A
    8/4/20177A
    7/7/20179A
    1/1/20179A
    5/5/20176A
    6/6/20171A
    1/1/20201B
    5/5/20205B
    3/3/20204B
    4/4/20207B
    6/6/20208B
    5/7/20199B
    4/6/20196B
    7/7/20195B
    1/1/20191B
    7/7/20182B
    5/5/20183B
    9/9/20186B
    7/7/20184B
    8/4/20171B
    7/7/20175B
    1/1/20174B
    5/5/20177B
    6/6/20171B

     

    2.Create a fiscal calendar, starting with May of each year.

    Calendar =
    ADDCOLUMNS (
        CALENDARAUTO ( 4 ),
        "Fiscal year",
            VAR fy =
                IF (
                    MONTH ( [Date] ) <= 4,
                    VALUE ( FORMAT ( [Date], "YY" ) ) - 1,
                    VALUE ( FORMAT ( [Date], "YY" ) )
                )
            RETURN
                CONCATENATE ( "FY ", fy )
    )

     

    3.Create a Fiscal year table by entering data.

     

    4.The relationships are as follows.

     

    5.Create a measure to filter the current year and the previous year.

    Measure = 
    VAR _year =
        SELECTEDVALUE ( 'Fiscal year'[FY] )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            FILTER (
                'Calendar',
                [Fiscal year] = _year
                    || [Fiscal year]
                        = "FY "
                            & RIGHT ( _year, 2 ) - 1
            )
        )
    v

     

    6.Put the measure into the Values of the matrix. The result is this.

     

     

    You can check more details from here.

     

    Best Regards,

    Stephen Tao

     

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Rajendrabobade ,

     

    1.My sample data is this.

    DateSalescategory type

    1/1/20201A
    5/5/20202A
    3/3/20203A
    4/4/20206A
    6/6/20205A
    5/7/20194A
    4/6/20191A
    7/7/20192A
    1/1/20193A
    7/7/20186A
    5/5/20184A
    9/9/20188A
    7/7/20187A
    8/4/20177A
    7/7/20179A
    1/1/20179A
    5/5/20176A
    6/6/20171A
    1/1/20201B
    5/5/20205B
    3/3/20204B
    4/4/20207B
    6/6/20208B
    5/7/20199B
    4/6/20196B
    7/7/20195B
    1/1/20191B
    7/7/20182B
    5/5/20183B
    9/9/20186B
    7/7/20184B
    8/4/20171B
    7/7/20175B
    1/1/20174B
    5/5/20177B
    6/6/20171B

     

    2.Create a fiscal calendar, starting with May of each year.

    Calendar =
    ADDCOLUMNS (
        CALENDARAUTO ( 4 ),
        "Fiscal year",
            VAR fy =
                IF (
                    MONTH ( [Date] ) <= 4,
                    VALUE ( FORMAT ( [Date], "YY" ) ) - 1,
                    VALUE ( FORMAT ( [Date], "YY" ) )
                )
            RETURN
                CONCATENATE ( "FY ", fy )
    )

     

    3.Create a Fiscal year table by entering data.

     

    4.The relationships are as follows.

     

    5.Create a measure to filter the current year and the previous year.

    Measure = 
    VAR _year =
        SELECTEDVALUE ( 'Fiscal year'[FY] )
    RETURN
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            FILTER (
                'Calendar',
                [Fiscal year] = _year
                    || [Fiscal year]
                        = "FY "
                            & RIGHT ( _year, 2 ) - 1
            )
        )
    v

     

    6.Put the measure into the Values of the matrix. The result is this.

     

     

    You can check more details from here.

     

    Best Regards,

    Stephen Tao

     

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