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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
canary
Regular Visitor

Calculating Stock Days

Hi, I'm newbie with Power BI, DAX and reports. I hope you can help me. Thank you!

I created a new measure which calculates the difference between two dates from a filter, but when i use the measure in a column the contained value turns static.



As you can see in the video, the column value is static. I don't know if this is a problem or it isn't in the future.

The table is filtered by id.

For make the measure i used this code:

Measure Diff = 
var start_Date=FIRSTDATE(ALLSELECTED('Calendario de Ventas'[Date]))
var end_Date=LASTDATE(ALLSELECTED('Calendario de Ventas'[Date]))
return
DATEDIFF(start_Date;end_Date;DAY)

I need create columns with stock days (i think that it's the formula, but i dont know how works DIVIDE):

DIVIDE(stock_boulevard;ventas_boulevard;0)*diff_two_dates

I think that can be important to share a picture of tables relations:
bi1.png
unidades por almacén = units by warehouse
métodos de pago = payment methods
ventas = sells
fechas ventas = sells dates
po_id = order id

Any idea?

Thank you again.

2 REPLIES 2
v-yuezhe-msft
Employee
Employee

@canary,

Do you mean that the Column diff field doesn't change based on slicer selection? If so,  this behavior is expected as  calculate columns are computed during database processing(e.g. data refresh) and then stored in the model, they do not response to user selections on the report.  for more details, please review this Knowledge base.

Based on your description, you want to calculate stock days, could you please share dummy data of your tables and post expected result here?

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yuezhe-msft, sorry for delay. I was working hard this week.

I understand your response. The calculated columns which select the values from measures cannot change dynamically.

So... then it's possible to do with measures?

I can provide a CVS file of the last 100 sales of a product.

I cant provide with more because isnt my company .

In this set, if I use the time slider, I wanna take the following results with 200 stock units:

Formula= (Stock / Sales) * Days

Seeing the table, from all the time I sold 125 units in 223 days. Result = (200/125) * 223 = 356,8

But if I select the dates from January 02/01/2018 - 10/01/2018 (spanish format), I have that i sold 51 units in 8 days. Result = (200/51) * 8 = 31,37

Its possible to do this for each product?

Thank you and sorry for de delay again.

This is the file link.csv

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.