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
Anonymous
Not applicable

using calculate function

Hi All,

 

Im new to power BI and i am having issue creating a DAX formula to achieve the result below

 

Table 1

IDDescriptionLocationRemarkFrom DateEnd Date
1234AppleLondonSold01-01-2001-01-21
1235MangoParisSold05-03-1907-01-20
1235MangoBerlinAvailable08-01-2009-12-21
1236PearLondonSold15-08-1904-01-21
1237OrangeBrusselsSold19-09-1917-03-22

 

 

Table 2

IDDescriptionQty
1234Apple7
1235Mango9

1236

Pear8

1237

Orange6

 

Relationship: Table1 *:1 Table2

Question:

I would like to create a measure that shows the amount of fruits available within a particular period. 

ie 

Item2019202020212022
Apple77(-1) =66+17
Mango9(-1) = 88(+1) =99-18
Pear8(-1) =777+18
orange6(-1)= 5556

 

Expected Result:

I intend to have the sum of all Item available on my Y axis and the Year on the X axis. 

 

 

Thank you as i anticipate your suggestions and responses

 

4 REPLIES 4
JarroVGIT
Resident Rockstar
Resident Rockstar

I really can't follow your logic. Why is Apple in 2020 7-1=6?  And ID in Table 1 is the same ID in table 2? What do the end dates say? And start dates? In other words: please explain your tables a bit, this seems like a very rare datamodel to be honest.

Thanks!

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi @JarroVGIT 

 

Thank you for your response.

I can imagine that the logic is a bit complex. However, to answer your questions

Q1: Why is Apple in 2020 7-1=6?

 

Apple in 2020 is 7 -1 = 6 because from the inventory (table 2), the total amount of apples are 7 and in 2020 and apple is rented out from 01-01-20 till 01-01-21 (table 1, row 1). The means that the apple with ID 1234 would be reduced by 1 from 01-01-20 i.e "from date" , till the01-01-21 i.e "end date" when it becomes available again. 

Remark: Sold = Rented (when item is rented, 1 is subtracted(-1) from the total qty in the inventory(table 2)

                          Available (when item is rented, 1 is added (+1) from the total qty in the inventory(table 2)

 

Q2: ID in Table 1 is the same ID in table 2?

Yes, the ID's are the same. The ID are unique identifiers for the items. the relationship is a many to one relationship.

 

The whole idea is to create a measure to know the qty of items in the inventory that are available to be rented out everytime(in this case yearly). 

 

Lets me know if it is clear now @JarroVGIT 

 

Best Regards,

Charlie101

 
 

I think I see your point what you are trying to achieve but the logic is very incomplete. What if an item is returned mid year? Then it is counted as inventory in that year, but if it is returned on 31-12, it isn't? Where is that border, what if it is rented till 30-12? Why is there a line for available for Mango but not for the others?
My tip for you is: reconsider your datamodel and logic you want to apply, as this will become messy quickly.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

 

Thanks for the tip @JarroVGIT !

 

The from date and the end date in table 1 would be linked to a date table. With the date table, the date can be shown as Day, Months or Year. 

Available implies that the item has been returned and is available to be rented out for the period between the start date till the end date

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.