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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Measure to convert previous weeks value to 0

Hello Everyone!

 

I am connecting to Azure Table Storage and showing multiple attributes and Values by week. The weeks are formatted as w192001, w192002 with 1920 as fiscal year and last 2 digits are week number. In the attached file, I am showing Metrics Category and SubCategory. Actual data is at far lower grain than Metric-Week combination but I guess that doesn't matter as I am already covering few here.

 

What is needed - When I refresh the report each week, all other Metrics are fine but for Defected, I should make value for all previous weeks as 0 while for others it should be whatever is coming from table. I cannot use calculated table as the table contains around 50M rows and data is increasing every week.


The date table can be created in a different way if needed.

 

Please suggest how to create a measure for this calculation:-

 

IF WeekinData < CurrentWeek AND Metric = Defected, then Value = 0 ELSE Value = Value. ( Complexity here is to first calculate current week from date table and then compare it with week and metric in data table. I am also trying to avoid calculating another column to conver week in weeknbr like w192001 to just 192001, so that should be taken care within the measure).

 

**In actual report, I have around 200 metrics and this calculation is needed for 5.

 

Sample Data

WeekIDMetricCategorySub-CategoryValue
w192001Sold UnitsElectronicsLaptops2100
w192001DefectedElectronicsLaptops10
w192001OrderedElectronicsLaptops1500
w192002Sold UnitsElectronicsLaptops2500
w192002DefectedElectronicsLaptops2
w192002OrderedElectronicsLaptops1800
w192003Sold UnitsElectronicsLaptops2200
w192003DefectedElectronicsLaptops15
w192003OrderedElectronicsLaptops1000

 

DateWeekID
20/07/2020w192001
21/07/2020w192001
22/07/2020w192001
23/07/2020w192001
24/07/2020w192001
25/07/2020w192001
26/07/2020w192001
27/07/2020w192002
28/07/2020w192002
29/07/2020w192002
30/07/2020w192002
31/07/2020w192002
01/08/2020w192002
02/08/2020w192002
03/08/2020w192003
04/08/2020w192003
05/08/2020w192003
06/08/2020w192003
07/08/2020w192003
08/08/2020w192003
09/08/2020

w192003

 

Expected Result:-

 WeekID
Metricw192001w192002w192003
Sold Units210025002200
Defected0015
Ordered150018001000

 

Thank You!

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , refer if these can help

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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