cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Amardeep100115
Post Prodigy
Post Prodigy

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

 

 

Result.png

 

 

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

Main graph.png

AB
1 ACCEPTED SOLUTION
Eyelyn9
Community Support
Community Support

Hi @Amardeep100115 ,

 

I have built a data sample for test.

Year-Value data sample.PNG

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:

Year for slicer.PNG

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:

select-no selected.PNG

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.

View solution in original post

2 REPLIES 2
Eyelyn9
Community Support
Community Support

Hi @Amardeep100115 ,

 

I have built a data sample for test.

Year-Value data sample.PNG

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:

Year for slicer.PNG

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:

select-no selected.PNG

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.

View solution in original post

parry2k
Super User
Super User

@Amardeep100115 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.






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors