Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

On current selection of filter should show last 12 month data

I have two filter in report, one for fiscal year & other for fiscal month. On current selection of fiscal year & fiscal month, the entire page should last 12 month of data. Suppose if I choose "Jan" as fiscal month & "2017" as fiscal year then it must show previous 12 month of data from fiscal month Jan 2017. Please Guide...

Thanks in advance.

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

Based on my test, we can take the following steps to meet your requirement.

 

1. Enter the data as you described, and create a new column.

Yearmonth = YEAR(Table1[date])*100+MONTH(Table1[date])

2. Create a YearMonth table and add an index column

distime = DISTINCT(Table1[Yearmonth])
MonthIndex = 
VAR MonthRow = distime[YearMonth]
RETURN
    CALCULATE (
        DISTINCTCOUNT ( distime[YearMonth] ),
        FILTER ( distime, 'distime'[YearMonth] <= MonthRow )
    )


3. Create the three measures as below.

monthtocheck = CALCULATE(MAX(distime[MonthIndex]),ALLSELECTED('Calendar'[YearMonth]))
SelectMonthIndex = 
    CALCULATE (
        MAX ( distime[MonthIndex] ),
        FILTER (ALL(distime), (SELECTEDVALUE(FY[Year])*100+SELECTEDVALUE('Month'[month]))=distime[YearMonth]))
Previsou 12 = IF(AND([monthtocheck]>[SelectMonthIndex]-12,[monthtocheck]<=[SelectMonthIndex]),1,0)

4. Create a table visual and filter the table making the Previsou 12 is 1. Then we can get the result as below.

 

1.png

 

For more details, please check the pbix as attached.

https://www.dropbox.com/s/y4pcfw8kburinob/On%20curren2.pbix?dl=0

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @Anonymous,

 

Based on my test, we can take the following steps to meet your requirement.

 

1. Enter the data as you described, and create a new column.

Yearmonth = YEAR(Table1[date])*100+MONTH(Table1[date])

2. Create a YearMonth table and add an index column

distime = DISTINCT(Table1[Yearmonth])
MonthIndex = 
VAR MonthRow = distime[YearMonth]
RETURN
    CALCULATE (
        DISTINCTCOUNT ( distime[YearMonth] ),
        FILTER ( distime, 'distime'[YearMonth] <= MonthRow )
    )


3. Create the three measures as below.

monthtocheck = CALCULATE(MAX(distime[MonthIndex]),ALLSELECTED('Calendar'[YearMonth]))
SelectMonthIndex = 
    CALCULATE (
        MAX ( distime[MonthIndex] ),
        FILTER (ALL(distime), (SELECTEDVALUE(FY[Year])*100+SELECTEDVALUE('Month'[month]))=distime[YearMonth]))
Previsou 12 = IF(AND([monthtocheck]>[SelectMonthIndex]-12,[monthtocheck]<=[SelectMonthIndex]),1,0)

4. Create a table visual and filter the table making the Previsou 12 is 1. Then we can get the result as below.

 

1.png

 

For more details, please check the pbix as attached.

https://www.dropbox.com/s/y4pcfw8kburinob/On%20curren2.pbix?dl=0

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Thanks for the solution.

 

I need one more help:

 

1. On another page, I have Fiscal year filter, on a current selection, it must show selection fiscal year data & previous two fiscal years of data.

 

2. On another page, I want a Fiscal quarter filter such that, on a current selection, it must show the selected fiscal quarter as well as previous three-quarters data.

 

I'm sharing you .pbix file:

https://www.dropbox.com/s/any7ernb6sz14x1/Test.pbix?dl=0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.