March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello, I am working with data from cattleraising. I am currently facing a challenge and haven't been able to work around it. I have a two tables, Table 1 with 3 columns, [ID], [Date] and [Kg]. The other table is a Calendar table. On Table 1 there are several Dates for when [ID] have been weighted throughout the year.
I have created a measure called [GDP] to calculate the wieght gained per day between one Date and the next for each [ID]. Now i am trying to to find the average of [GDP] of all [ID] for each day in the Calendar table, regardless of each [ID] having a Date in Table1.
Example of Table 1
Date | ID | Kg |
15/01/2024 | 00001 | 150 |
20/01/2024 | 00001 | 155 |
25/01/2024 | 00001 | 165 |
[GDP] of ID 00001 between dates 1 and 2 is 1 kg/day where GDP is (155-150)/(5)
[GDP] of ID 00001 between dates 2 and 3 is 2 kg/day where GDP is (165-155)/(5)
Example of table needed and don't know how to get it:
Date | GDP |
16/01/2024 | 1 |
17/01/2024 | 1 |
18/01/2024 | 1 |
19/01/2024 | 1 |
20/01/2024 | 1 |
21/01/2024 | 2 |
22/01/2024 | 2 |
23/01/2024 | 2 |
24/01/2024 | 2 |
25/01/2024 | 2 |
If anyone can help, thanks in advanced!
Solved! Go to Solution.
You are absolutely right!
Thanks.
I created a new table instead of using as measure, so I can relate to a calendar table and work with it. Thanks @lbendlin
This is a standard intrapolation.
GPD =
var d = SELECTEDVALUE('Calendar'[Date])
var pd = maxx(filter('Table',[Date]<d),[Date])
var nd = minx(filter('Table',[Date]>=d),[Date])
var pv = maxx(filter('Table',[Date]=pd),[Kg])
var nv = maxx(filter('Table',[Date]=nd),[Kg])
return if(not ISBLANK(pd) && not ISBLANK(nd),pv + DIVIDE(nv-pv,nd-pd,0)*(d-pd))
Sorry, I didn't explain myself thouroghly.
I have created a sample dataset to try and explain myself better. This is a visual from my sample table.
I need a way to average the GDP for the months (or days) in between the data as well. GDP would be the change of KG between the weighting days. I need to get to this:
Where the cells in yellow is the GDP but for dates/months where there is no data. In the visual we can see there is no data for december 2023, so the GDP for that ID from January 24 is reflected in dec 23, because that ID had a change of KG of 0,400 per day. So the average per month would indeed reflect the change for every ID for every month.
Thanks for the patience and the help!
This is the link for my sample data:
SAMPLEPOWERBI
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
93 | |
87 | |
84 | |
77 | |
49 |
User | Count |
---|---|
160 | |
144 | |
103 | |
74 | |
57 |