Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Please guide on graph

Hi, 

 

I wish to filter below graph on different logic, 

 

1) If i select month from any fiscal year the graph should filter for that Fiscal year. like below image. in below image i have selected fiscal year

 

 

 

 

2) If there is no option selected then it should filter for currunt fiscal year. my graph is like below image

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    I have built a data sample for test.

    According to my understanding,

    1.If no year selected , show the current year, 2 years before.

    2.If year selected, show the selected value

     

    If so , you need create a new table with Year for slicer:

    Then use the following formula to create a measure:

    Measure = 
    VAR _sele =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[Year] IN ALLSELECTED ( 'ForSlicer'[Year] ) )
        )
    VAR _nosele =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                'Table',
                'Table'[Year] - YEAR ( TODAY () ) >= -2
                    && 'Table'[Year] - YEAR ( TODAY () ) <= 0
            )
        )
    RETURN
        IF ( ISFILTERED ( 'ForSlicer'[Year] ), _sele, _nosele )

    The final output is shown below:

    If it does not make sense, please share me with your pbix file after removing sensitive data.

     

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

2 Replies

  • Anonymous maybe change your measure as below that shows the value for the line

     

    Sales Default = 
    VAR __selectedYear = CALCULATE ( MAX ( 'Calendar'[Year] ), ALLSELECTED ( 'Calendar'[Year] ) ) 
    RETURN
     CALCULATE ( SUM ( Table[Sales] ), KEEPFILTERS ( TREATAS ( { __selectedYear }, 'Calendar'[Year] ) ) )

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    I have built a data sample for test.

    According to my understanding,

    1.If no year selected , show the current year, 2 years before.

    2.If year selected, show the selected value

     

    If so , you need create a new table with Year for slicer:

    Then use the following formula to create a measure:

    Measure = 
    VAR _sele =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER ( 'Table', 'Table'[Year] IN ALLSELECTED ( 'ForSlicer'[Year] ) )
        )
    VAR _nosele =
        CALCULATE (
            SUM ( 'Table'[Value] ),
            FILTER (
                'Table',
                'Table'[Year] - YEAR ( TODAY () ) >= -2
                    && 'Table'[Year] - YEAR ( TODAY () ) <= 0
            )
        )
    RETURN
        IF ( ISFILTERED ( 'ForSlicer'[Year] ), _sele, _nosele )

    The final output is shown below:

    If it does not make sense, please share me with your pbix file after removing sensitive data.

     

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