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
Kenta
Frequent Visitor

Show only last week ending inventory

Hi,

 

I receive files weekly from dealers that include sales and inventory which I consolidate/append to all previous data they've sent me. I would like to have a column in my table that shows inventory levels for only the last week of the selected period.

 

Example: If I select multiple weeks with my slicer, the "Total Inventory" column which is currently a sumx measure of all dealer files will sum all weekly inventory levels for the selected period which creates a grossely overstated inventory picture.

 

Kenta_0-1643339661767.png

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Kenta , Try

calculate(lastnonblankvalue(Date[Week End Date], [Total Inv]))


or have week rank on week start date or week end date in a date table
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format


Then try measures like
This Week = CALCULATE([Total Inv], FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE([Total Inv], FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Kenta , Try

calculate(lastnonblankvalue(Date[Week End Date], [Total Inv]))


or have week rank on week start date or week end date in a date table
Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
OR
Week Rank = RANKX(all('Date'),'Date'[Year Week],,ASC,Dense) //YYYYWW format


Then try measures like
This Week = CALCULATE([Total Inv], FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE([Total Inv], FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

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.