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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

How to show past 12 months of data from current month

Hello All

I have a table with the following columns

MonthUsageyear

Jul

5645

2022

Agu

1656

2022

Sep

4465

2022

Oct

456

2022

Nov

46546

2022

Dec

15

2022

Jan

2165

2022

Feb

546

2022

Mar

3541

2022

Apr

56

2022

May

516

2022

Jun

8996

2022

Jul

265

2023

Agu

1565

2023

Sep

454

2023

Oct

122

2023

Nov

2165

2023

Dec

5456

2023

Jan

4654

2023

Feb

57

2023

Mar

74

2023

Apr

75

2023

May

754

2023

Jun

5645

2023

Jul

8785

2024

Agu

74

2024

Now I have to show the past 12 months of data from the current month I am using bar chart to show this data

So now we are in the August so I have to show the Bars from August 2023 to August 2024

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

Consider a new date column:

vcgaomsft_0-1692087982865.png

Create a date table and a measure:

Model:

vcgaomsft_1-1692089044877.png

Measure:

Measure = 
VAR _max_date = CALCULATE(MAX('Table'[Date]),ALL())
VAR _min_date = EOMONTH(_max_date,-13) + 1
VAR _cur_date = MIN('Date'[Date])
VAR _visual_filter = IF(_cur_date>=_min_date&&_cur_date<=_max_date,1)
RETURN
_visual_filter

Apply the measure to the visuals filter:

vcgaomsft_2-1692089100402.png

Output:

vcgaomsft_3-1692089129651.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

Consider a new date column:

vcgaomsft_0-1692087982865.png

Create a date table and a measure:

Model:

vcgaomsft_1-1692089044877.png

Measure:

Measure = 
VAR _max_date = CALCULATE(MAX('Table'[Date]),ALL())
VAR _min_date = EOMONTH(_max_date,-13) + 1
VAR _cur_date = MIN('Date'[Date])
VAR _visual_filter = IF(_cur_date>=_min_date&&_cur_date<=_max_date,1)
RETURN
_visual_filter

Apply the measure to the visuals filter:

vcgaomsft_2-1692089100402.png

Output:

vcgaomsft_3-1692089129651.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

eliasayyy
Memorable Member
Memorable Member

since you dont have an actual date and they are just text and year is number , it can be tricky but solvable 

first add index to your table i npower query

annonymous1999_0-1691675777695.png


next create a filetr measure

 

Filter Out = 
VAR _t = TODAY()
VAR _tmy = FORMAT(_t, "mmm-yyyy")
VAR _i = CALCULATE(MAX('Table (2)'[Index]), ALL('Table (2)'), 'Table (2)'[Month] & "-" & 'Table (2)'[Year] = _tmy)
RETURN
IF( AND(MAX('Table (2)'[Index]) >=_i,MAX('Table (2)'[Index]) <=_i+12),1,0)

 


this measure will find when is today mont hand year and then return the index of this month-year then it will make a condition to return 1 if the indexes are in this range between todays month -year and after 12 months

add this emsaure to your filter panel 
and let it be equal to 1

annonymous1999_1-1691675931421.png


i would advise to make it easier by havng actual date format 

and in case you have multiple duplicate month - year value , just use pwoer query make a new column called "Month-Year" combine them and then duplicate the table and remove duplicate values of month-year and just create a relationship between both tables

best regard

if i solved your question leave a thumbs up and accept as solution

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.