Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi friends, Im new in this community, and im working with power Bi around 6 months, and its great!!
Im trying to make a meassure in power Bi desktop, i got a database of daily stocks and different kind of inventory status (like scrap or expired stock). I have records of the stock by the end of each month, and i have to do a formula to calculate de difference of the stock in one month minus the stock of the previous month, to make a KPI of the gap of the scraps in each month. (comparing the stock of one month - the stock of the previous month) and be able to graph it.
i Cant do it in the meassure, can you please help me how to do it?
Thank you so much, i dont speak english so far :P, i hope you can understand it.
Solved! Go to Solution.
Hi @clopez,
First, please create a calendar table using formula. I assume table name stored stock records is 'Stock'.
Calendar=CALENDAR(MIN(Stock[date]), TODAY())
Then create a relationship between 'Stock' table and Calendar table by date field. More details, please review: Create and manage relationships in Power BI Desktop. Create a calculated column to get month using formula: Month=Month(Calendar[Date])
Finally, create a measure using the formula. And create a table visual, select the month and measure as value, you will get the difference in each month.
difference = COUNT ( Stock[record] ) - CALCULATE ( COUNT ( Stock[record] ), PREVIOUSMONTH ( Calendar[Date] ) )
Please know how the PREVIOUSMONTH work from here: https://msdn.microsoft.com/en-us/library/ee634758?ui=en-US&rs=en-US&ad=US.
And there are similar threads for your references.
Calculate difference from previous month
Comparison- current month vs previous month
Best Regards,
Angelia
Hi @clopez,
Have you resolved your issue? If you have, welcome to share your solution or mark the right reply as answer. More people will benefit from here.
Best Regards,
Angelia
Hi @clopez,
First, please create a calendar table using formula. I assume table name stored stock records is 'Stock'.
Calendar=CALENDAR(MIN(Stock[date]), TODAY())
Then create a relationship between 'Stock' table and Calendar table by date field. More details, please review: Create and manage relationships in Power BI Desktop. Create a calculated column to get month using formula: Month=Month(Calendar[Date])
Finally, create a measure using the formula. And create a table visual, select the month and measure as value, you will get the difference in each month.
difference = COUNT ( Stock[record] ) - CALCULATE ( COUNT ( Stock[record] ), PREVIOUSMONTH ( Calendar[Date] ) )
Please know how the PREVIOUSMONTH work from here: https://msdn.microsoft.com/en-us/library/ee634758?ui=en-US&rs=en-US&ad=US.
And there are similar threads for your references.
Calculate difference from previous month
Comparison- current month vs previous month
Best Regards,
Angelia
User | Count |
---|---|
90 | |
74 | |
67 | |
63 | |
55 |
User | Count |
---|---|
102 | |
93 | |
73 | |
60 | |
59 |