cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShivaPrasad1 Regular Visitor
Regular Visitor

Passing month and year parameters to filter the visuals.

Hello Team,

 

I have 3 years of data and counting in my data set. Date column is in the format of 2018.02, 2018.03 etc..I should have two slicers to select year and month. Based on the selection of slicers I need to show previous 12 months of data. Can I achieve this using paramters? If yes, can you show me the way please. It should be flexible to change the values as well to view different range of date values of data.

 

Also appreciated, if the solution can work for Power BI service as well.

 

Ex: 

Parameter 1 : 2017, Paramter 2: 08

 

Output should be like:

2016.09 to 2017.08 data

Thanks in advance.

 

Regards,

Shiva

 

3 REPLIES 3
ShivaPrasad1 Regular Visitor
Regular Visitor

Visuals rollback to previous 12 months based on selected month and year in filter

Hello Team,

 

I have 3 years of data and counting in my data set. Date column is in the format of 2018.02, 2018.03 etc..I am having two slicers to select year and month. Based on the selection of slicers I need to show previous 12 months of data. 

 

Also appreciated, if the solution can work for Power BI service as well.

 

Ex: 

Slicer 1 : 2017, Slicer 2: 08

 

Output should be like:

2016.09 to 2017.08 data

Thanks in advance.

 

Regards,

Shiva

 

Super User
Super User

Re: Passing month and year parameters to filter the visuals.

Basically something along the lines of:

 

Measure =
VAR __param1 = MAX('Table'[Parameter 1])
VAR __param2 = MAX('Table'[Parameter 2])
RETURN SUMX(FILTER('Table',([Year]>=__param1-1&&[Month>__param2)&&([Year]=__param1&&[Month]<=__param2)),[Data])

Tough to be specific without data. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


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

Proud to be a Datanaut!


Highlighted
Community Support Team
Community Support Team

Re: Passing month and year parameters to filter the visuals.

Hi @ShivaPrasad1

 

You may try to create measure as below. Here is the reference for you.

https://community.powerbi.com/t5/Desktop/Show-last-13-months-based-on-user-single-slicer-selection/m...

 

Measure  =
VAR par1 =
    SELECTEDVALUE ( 'Slicer'[Year] )
VAR par2 =
    SELECTEDVALUE ( 'Slicer'[Month] )
RETURN
    CALCULATE (
        MAX ( 'Table'[YearMonth] ),
        FILTER (
            'Table',
             'Table'[Date]  >= EDATE ( DATE ( par1, par2, 31 ), -11 )
                &&  'Table'[Date]  <= DATE ( par1, par2, 31 )
        )
    )

Sample file is here.

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.