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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Daredevilz
Regular Visitor

Show previous 4 weeks value of Dax based on selected week value in slicer

I have a multiple DAX which are giving me different parameters value.

I have a slicer of week selection in my report.

Now I want to show graph of last 4 weeks values of all DAX measure in graph based on single selection in week slicer.

For eg. In slicer if i selected 45, in graph it should x axis as 41, 42,43 and 44 against which i get DAX values.

 

I have a dim_date column which has date,weekofyear and other columns. That dim_date is one dimension date table used in the report.

1 ACCEPTED SOLUTION
saurabhtd
Resolver II
Resolver II

@DaredevilzHere is the DAX logic which might work in your case. 

 

Previous 4 Weeks Value = 
VAR SelectedWeek = SELECTEDVALUE(dim_date[WeekofYear])
RETURN
CALCULATE(
    [Base Measure],
    FILTER(
        ALL(dim_date),
        dim_date[WeekofYear] >= SelectedWeek - 4 && dim_date[WeekofYear] < SelectedWeek
    )
)

 

I you want to create line chart or bar chart. Add the Previous 4 Weeks Value measure to the y-axis and
Add the dim_date[WeekofYear] column to the x-Axis.

 

View solution in original post

1 REPLY 1
saurabhtd
Resolver II
Resolver II

@DaredevilzHere is the DAX logic which might work in your case. 

 

Previous 4 Weeks Value = 
VAR SelectedWeek = SELECTEDVALUE(dim_date[WeekofYear])
RETURN
CALCULATE(
    [Base Measure],
    FILTER(
        ALL(dim_date),
        dim_date[WeekofYear] >= SelectedWeek - 4 && dim_date[WeekofYear] < SelectedWeek
    )
)

 

I you want to create line chart or bar chart. Add the Previous 4 Weeks Value measure to the y-axis and
Add the dim_date[WeekofYear] column to the x-Axis.

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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