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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
lennox25
Post Patron
Post Patron

Help to show the last 12 weeks of rolling data in a line chart

Hi, 

 

I have a line chart and I only need it to show the last rolling 2 weeks of data. I have put a date filter on (using the date table) and the line chart X-axis used week no and period no from the sales table. Its pulling through incorrectly in terms of showing zeros for anything beyond 12 weeks when I want it to start on the line chart from the week 202335 (end of 202308) How can I make this work?

lennox25_0-1708681877363.png

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@lennox25 , if you have selected 12 weeks and it shows 0 for all other weeks, means you are using +0 or coalesce or blank handling in your measure avoid that.

 

In case you are adding +0 for in between range data try like

 

0 between range
Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1)

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @lennox25 ,

I created some data:

vyangliumsft_0-1708928139386.png

 

 

Here are the steps you can follow:

1. Create slicer table.

Slicer =
DISTINCT('Table'[year_week])

vyangliumsft_1-1708928139386.png

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Slicer'[year_week])
var _maxdate=MAXX(FILTER(ALL('Table'),'Table'[year_week]=_select),[Date])
var _mindate=DATE(YEAR(_maxdate),MONTH(_maxdate)-3,DAY(_maxdate))
return
IF(
    MAX('Table'[Date])>=_mindate&&MAX('Table'[Date])<=_maxdate,SUMX('Table','Table'[rand]),BLANK())

3. Result:

vyangliumsft_2-1708928163736.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @lennox25 ,

I created some data:

vyangliumsft_0-1708928139386.png

 

 

Here are the steps you can follow:

1. Create slicer table.

Slicer =
DISTINCT('Table'[year_week])

vyangliumsft_1-1708928139386.png

2. Create measure.

Measure =
var _select=SELECTEDVALUE('Slicer'[year_week])
var _maxdate=MAXX(FILTER(ALL('Table'),'Table'[year_week]=_select),[Date])
var _mindate=DATE(YEAR(_maxdate),MONTH(_maxdate)-3,DAY(_maxdate))
return
IF(
    MAX('Table'[Date])>=_mindate&&MAX('Table'[Date])<=_maxdate,SUMX('Table','Table'[rand]),BLANK())

3. Result:

vyangliumsft_2-1708928163736.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

amitchandak
Super User
Super User

@lennox25 , if you have selected 12 weeks and it shows 0 for all other weeks, means you are using +0 or coalesce or blank handling in your measure avoid that.

 

In case you are adding +0 for in between range data try like

 

0 between range
Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1)

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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