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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
harshagraj
Post Partisan
Post Partisan

To get Last 6 weeks in Fiscal week column

Hi all, I have a column called Fiscal Week Number and it has 1-27 weeks(I filtered 2020). Now for a KPI chart i have to display last 6 weeks and i am using C.Billings as a calculated measure . Please help me how to achieve it. I am using POWER BI default KPI card.
@v-jayw-msft 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @harshagraj 

 

Based on your description, I created data to reproduce your scenario.

Calendar(a calculated table):

 

 

Calendar = CALENDAR(DATE(2020,1,1),DATE(2020,12,31))

 

 


You may create a calculated column and a measure to diplay the data in last 6 weeks before today.

 

 

Calculated column:
weeknum = WEEKNUM('Calendar'[Date])

Measure:
var _cweeknum = WEEKNUM(TODAY())
var _weeknum = SELECTEDVALUE('Calendar'[weeknum])
var _cyear = YEAR(TODAY())
var _year = YEAR(SELECTEDVALUE('Calendar'[Date]))
return
IF(
    _weeknum>=_cweeknum-6&&
    _weeknum<=_cweeknum&&
    _year=_cyear,
    1,
    0
)

 

 

 

Finally you may put the measure in the visual level filter. Here is the result. Today is 4/6/2020.

a3.png

 

Best Regards

Allan

 

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-alq-msft
Community Support
Community Support

Hi, @harshagraj 

 

Based on your description, I created data to reproduce your scenario.

Calendar(a calculated table):

 

 

Calendar = CALENDAR(DATE(2020,1,1),DATE(2020,12,31))

 

 


You may create a calculated column and a measure to diplay the data in last 6 weeks before today.

 

 

Calculated column:
weeknum = WEEKNUM('Calendar'[Date])

Measure:
var _cweeknum = WEEKNUM(TODAY())
var _weeknum = SELECTEDVALUE('Calendar'[weeknum])
var _cyear = YEAR(TODAY())
var _year = YEAR(SELECTEDVALUE('Calendar'[Date]))
return
IF(
    _weeknum>=_cweeknum-6&&
    _weeknum<=_cweeknum&&
    _year=_cyear,
    1,
    0
)

 

 

 

Finally you may put the measure in the visual level filter. Here is the result. Today is 4/6/2020.

a3.png

 

Best Regards

Allan

 

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

Please create a week Rank,m using week start or week end date. That can we use to get the desired column

Refer this file : https://www.dropbox.com/s/d9898a48e76wmvl/sales_analytics_weekWise.pbix?dl=0

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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