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.
Hello!
I Have the following problem, I have 3 columns: My initial Date, Final Date, and production between the dates, like the folowwing example:
Initial Date | Finish Date | Production |
01//01/2018 | 01//01/2019 | 365 |
I want to make a measure that divide the production by the numbers of days and list that in my calendar table, with all the dates included.
Thanks in advance!
Solved! Go to Solution.
Hi @Anonymous
You may add a column for the sample table:
Days = DATEDIFF(Table[Initial Date],Table[Finish Date],DAY)
Then you may get the measure and show all the dates included.
Divide = CALCULATE ( DIVIDE ( MAX ( Table[Production] ), MAX ( Table[Days] ) ), FILTER ( GENERATE ( 'Calendar', Table ), 'Calendar'[Date] >= Table[Initial Date] && 'Calendar'[Date] <= Table[Finish Date] ) )
Regards,
Cherie
Hello!
I discovered a little issue that caused a big problem for me...
Basically the given answers worked really fine if you have only date type, but my data presents DATE and TIME information, so it should be a little like this...
Attributte | Initial Date- time | Finish Date - time | Production |
A | 01//01/2018 00:00 | 01//03/2019 12:00 | 60 |
B | 01/03/2018 12:00 | 01/04/2018 23:59 | 36 |
So, if you follow the DAX formula on the column =
Days = DATEDIFF(Table[Initial Date],Table[Finish Date],DAY)
and the following measure =
Divide =
CALCULATE (
DIVIDE ( SUM ( Table[Production] ), SUM ( Table[Days] ) ),
FILTER (
GENERATE ( 'Calendar', Table ),
'Calendar'[Date] >= Table[Initial Date]
&& 'Calendar'[Date] <= Table[Finish Date]
)
)
The formula works well if you dont show it by atributte, but when I start adding atributte in any visual it gives me the "wrong answer".
What happens is that if I put that in a graph, it will show to me that between day 1 and 3, it produced and average of 20 of atributte A , but that is not true, because it stopped in the middle of the day (it should be 24 per day).
And the same will happen with the Atributte B, it wil show and average of 18 between day 3 and 4 even that started only in the middle of day 3(should be 24 also).
What will happen is that in the "transaction" day (day 3), it shows a production of 20 products A and 18 of product B, given me a total of 38, and not 24 has was suppose to be.
Basically I need to find a way of correcting the number bat also make it link with my calendar table....
The ideia is to have that number in the most acurrate way, in the minutes scale if possible.
Thanks in advance,
Hi @Anonymous
Could you tell me if your problem has been solved? If it is,kindly mark the helpful answer as a solution and welcome to share your own solution. More people will benefit from here. If not, please share more details for us so that we could help further on it.
Regards,
Cherie
Hi @Anonymous
You may add a column for the sample table:
Days = DATEDIFF(Table[Initial Date],Table[Finish Date],DAY)
Then you may get the measure and show all the dates included.
Divide = CALCULATE ( DIVIDE ( MAX ( Table[Production] ), MAX ( Table[Days] ) ), FILTER ( GENERATE ( 'Calendar', Table ), 'Calendar'[Date] >= Table[Initial Date] && 'Calendar'[Date] <= Table[Finish Date] ) )
Regards,
Cherie
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
97 | |
86 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |