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
martinl
Regular Visitor

sales and inventory reports

I am trying to buld a chart over 52 weeks that show Sales vs Inventory

At a weekly level there is no problem

However when I move out to a monthly view it goes wrong. This is because the Sales can be summed to get an end of month figure but the inventory cannot, it needs to be the Value at last week of each month.

 

How can I do this or am I asking too much.

 

In my data set I have another column with an eom flag in the data below it would show as 0 until 22/04/2017 where it would be 1 but I dont know how I can use this or if i need too. Maybe Power BI has this even already built in somewhere and I havent found it yet.

 

 ABCD
1ProductDateAttributeValue
2Widget01/04/2017Sales2
3Widget01/04/2017Inventory8
4Widget08/04/2017Sales3
5Widget08/04/2017Inventory9
6Widget15/04/2017Sales0
7Widget15/04/2017Inventory9
8Widget22/04/2017Sales1
9Widget22/04/2017Inventory7



Excel tables to the web >> Excel Jeanie HTML 4

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @martinl,

 

>>However when I move out to a monthly view it goes wrong. This is because the Sales can be summed to get an end of month figure but the inventory cannot, it needs to be the Value at last week of each month.

You can try to use WEEKNUM function to get last weeknum of current month, then use this result as condition to summary value.

Sample:

Last Weeknum of current Month = 
var currDate=MAX([Date])
return
WEEKNUM(Date(Year(currDate),Month(currDate)+1,1)-1,1)

 

Capture.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

From the way you describe it, I would write these two measures:

 

Sales := CALCULATE(SUM(MyTable[Value]), MyTable[Attribute] = "Sales")

Inventory := CALCULATE(SUM(MyTable[Value]), MyTable[Attribute] = "Inventory", MyTable[EOM] = 1)

Hi scottsen

Thank you for your reply and I apologise for not responding sooner.

Your solution has aided my quest to learn the tool but doesn’t quite solve my issue.

I have though used it as a solution and decided not to allow users to drill into the chart as this is where it goes wrong.

I liked the idea of users being able to drill into yearly, monthly, quarterly, weekly views and the sales worked wonderfully however the stock does not like this as the stock cannot be cumulatively summed but must always take the latest figure.

Anonymous
Not applicable

Because you mentioned "eom flag" I thought my technique would work, but typically handling inventory you just use LASTDATE( ) function, eg:

 

Inventory := CALCULATE(SUM(MyTable[Value]), MyTable[Attribute] = "Inventory", LASTDATE(Calendar[DateKey]))

 

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.