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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
chavanr
Resolver I
Resolver I

WTD, MTD & YTD dynamic axis as per the date range selected.

Hi there,

 

I am trying to build a visual for WTD, MTD & YTD with one slicer for date and second slicer for WTD,MTD & YTD. 

so when a user selects a specific date range untill today , they can get the values for WTD, MTD or YTD as per selection

 

 

Below is the bar chart visual which will give me the value for revenue as per the above selection , I want to display in the visual the x-axis dynamically , so when the user selects "YTD" they get view monthly. "WTD" to show the current week data in daily . "MTD" to show the current month.

 

But the view needs to change as per the selection in the main date slicer.

 

I have used calculation groups to get the WTD, MTD & YTD .

 

 WTD = VAR CurrentDate = LASTDATE('Date'[Full Date]) VAR DayNumberOfWeek = WEEKDAY(LASTDATE('Date'[Full Date]),2) RETURN CALCULATE( SELECTEDMEASURE(), DATESBETWEEN( 'Date'[Full Date], DATEADD( CurrentDate, -1*DayNumberOfWeek, DAY), CurrentDate

 

MTD = CALCULATE( SELECTEDMEASURE(), DATESMTD( 'Date'[Full Date] ))

YTD = CALCULATE(SELECTEDMEASURE(),DATESYTD('Date'[Full Date]))

And then created a Date Period table to create a slicer measure 

Date Periods =

vartodatdate = LASTDATE(FactWeighing[Weighing Date])

varWeekStart = CALCULATE(todatdate-WEEKDAY(todatdate,3),YEAR(FactWeighing[Weighing Date])=YEAR(todatdate))

varresults=

UNION(

ADDCOLUMNS(DATESMTD((FactWeighing[Weighing Date])),

"Type", "MTD","ID","2"),

ADDCOLUMNS(DATESYTD(FactWeighing[Weighing Date]),

"type","YTD","ID","3"),

ADDCOLUMNS(CALENDAR(WeekStart,todatdate),"Type","WTD","ID","1"))

return

results

 

 

Also created a relationship between Date table & the Dates period table.

 

I am not able to make the axis dynamic as per the user selection.

Can someone provide some suggestions.

 

Cheers

0 REPLIES 0

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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