The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now
Greetings, I use the following command in order to know calculate how many days there are between two dates:
DifferenceDays =
CALCULATE (
SUM ( 'Date'[Laborable] ),
DATESBETWEEN ('Date'[Date].[Date],DDBB[StartDate)]+0,DDBB[EndDate] )
)
The problem I am having is that if the start date was on the end of 2020 and the end date is at the beginning of 2021, this counts the days without having into account the yeras, so I get a period of 300+ days instead of 10-20 days.
How could I fix this issue?
Thanks!
Regards,
Hi @Anonymous ,
Can you describe SUM ( 'Date'[Laborable] ),? If you only calculate the time difference, please try to use DATEDIFF function.
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous It will be easier if you share pbix file using one drive/google drive with the expected output. Remove any sensitive information before sharing.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Anonymous remove .[Date] after first parameter in the function.
Also why you are adding +0 in the 2nd parameter.
DifferenceDays =
CALCULATE (
SUM ( 'Date'[Laborable] ),
DATESBETWEEN ('Date'[Date],DDBB[StartDate)]+0,DDBB[EndDate] )
)
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k !
Thanks for you reply, I have deleted the .[Date] but the issue is not solved, the count of days is still bigger than it should.
Regarding the "+0", I read somewhere it would cause the cases in which the amount of days i "0" to count as "0" instead of "null".
Thanks!
Regards,
User | Count |
---|---|
160 | |
111 | |
96 | |
86 | |
75 |
User | Count |
---|---|
158 | |
136 | |
133 | |
81 | |
61 |