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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
archerjayden
Helper I
Helper I

Custom Year Period X Axis that shows Last Year Last Period

Hi All,

I have a requirement to show on X-Axis Last Period of last Year plus all periods of current year … i.e.,Screenshot here
YearPeriod Desired Output

YearPeriod Desired Output.JPG

I already have a Column year period in format ex: "2021 P01"  that is coming from the SQL server table.
I have a single selector slicer on Fiscal Year i.e., 2020,2021,2022, etc.,
so based on Year selected, I should show this X-Axis dynamically to display only the last period of the previous year and all periods of the current year.

EDIT :
So Far I am able to get the last period last year value dynamically based on year slicer selection however I am unable to pass this as a filter to show as desired.

 

 

CustomYearPeriod = VAR MonthN = If(dim_date[CalendarMonth] < 10, "0" & dim_date[CalendarMonth],dim_date[CalendarMonth])
VAR TargetYear = VALUE(dim_date[FiscalYear])
VAR PreviousYr = TargetYear-1
Var MaxPeriod = Max(dim_date[CalendarMonth])
VAR Result =  CALCULATE(Min(dim_date[CalendarYearPeriod]),FILTER(dim_date,dim_date[CalendarYearPeriod] >=
PreviousYr &" P" & MaxPeriod))
Return Result

 

SamplePBIX 

Thanks,
Archer

1 REPLY 1
daxer-almighty
Solution Sage
Solution Sage

Create a new column in your calendar table and fill it in with 2 values. One value will mean "the last period last year or all periods of this year up to and including current", the other will mean the contrary. Then use this column to filter your visual/page/report via the Filter Pane.

 

Alternatively, use Calculation Groups to change all measures in one go so that they display BLANK when the item on the x-axis is not what you want. 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

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

Jan NL Carousel

Fabric Community Update - January 2025

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