I need to CALCULATE() the total number of hours throughout the years, but what I what I get is a ridiculous number - powerbi

I need to calculate the total of hours from the table 'Time Report[HH'] reardless of the date. The problem is that the result is much higher that what it actually is (4774 vs 68K (named REALESV2)).
Also, you can see how the curve drops after december :(
picture showing just 2022
picture showing 2022 and 2023
Thank you for your help!

Related

Why does powerbi average/day calculation become inaccurate over longer timespan?

I am trying to create a power BI calculation as an average per day of how many times a code was tripped. The dax calculcation that I have
Count Trips average per Day =
AVERAGEX(
KEEPFILTERS(VALUES('ruledata (2)'[Date].[Day])),
CALCULATE([Count Trips])
)
works fine when the average is being calculated over a couple days. I double checked this by hand and can confirm that it is accurate until at least 2 weeks. However once the time range increases to include months the average starts getting ridiculous and begins displaying average trips /day values that are much higher than the highest number of trips on a single day. I have confirmed that the data in the graph is correct
So I know that the values should reflect what is in the graph. In this two month example the DAX formula calculated the average to be 149.03 but the actual average/day should have been 82.8.
In general is there some sort of error in the DAX formula that I am using that could cause this?
I guess that 'ruledata (2)'[Date].[Day] is the day of the month. So if you take the average it will be wrong because when you take the average of e.g. March and April you will divide the total trips by 31, and not by 61 (30+31). So use 'ruledata (2)'[Date].[Date] instead.

Cumulative/Rolling Sum Blank Dates

I'm currently working on inventory reconciliation, and I've struggling to fill all days of the calendar with the cumulative sum of product we're currently storing:
Inventory level ($). = CALCULATE(SUM(ledger[cost]),FILTER(ALL(DimDate[Date]),DimDate[Date]<=MAX(ledger[Document Date])))
As you guys might notice it has at least 90% of all dates filled, however if we look closely to the graph, we can appreaciate March 5th of 2016 is missing just due to the fact there was no transaction during that day resulting on a blank value. However I'm trying to accomplish retrieving the previous day balance for those days with no transactions. e.g: for March 5th should have $17,038,462.32 (balance for the previous day March 4th).
I'm trying to work on another clause into the measure with functions such as EARLIER or LASTDATE, however I haven't been succesful.
Any insight or solutions works well thank you. Have a nice day.
You are using a wrong date field in your measure. Change it to the field from the Date table:
Inventory level. =
CALCULATE(
SUM(ledger[cost]),
FILTER(ALL(DimDate[Date]),DimDate[Date]<=MAX(DimDate[Date])))

How to divide project hours over project length with a known end date in Power BI

I'm trying to figure out how to spread the estimated hours for a project over the length of that project with a known end date.
Example, I have Project 001, it is 600 hours, and it is a six-month project that is due to release June 2020. Each of these values (project identifier, hours, length, and release date) are separate columns in a database.
In this example, Project 001 would add 100 hours to each month from January to June. If Project 002 had 300 hours with the same length and release date, now each month would have 150 hours.
The end goal is to get a forecast of how many hours we expect in each month for all the projects we have to determine the overall capacity demands for the month. So we'd have something like a bar chart that shows the total hours demand for each month based on the projects that will impact that month. Or we'd have a bar chart that shows the remaining capacity (fixed monthly capacity minus monthly estimated hours).
I haven't been able to determine how to generate something that will divide the hours backward over the length of the project based on the project end date. I'm still pretty new to Power BI, so I could do with some guidance on this one. I'm well versed in Excel and VBA, I understand the basics of creating measures and some of the ways Power BI "formulas" are written. Any help is much appreciated.
I made a small test table:
I added the column: HoursPerDay
HoursPerDay = Hours[Hours]/ DATEDIFF(Hours[StartDate];Hours[EndDate];DAY)
Next I made a calendar table:
Calendar = CALENDAR(MIN(Hours[StartDate]);MAX(Hours[EndDate]))
I added the measure HoursPerProject to this table:
HoursPerProject = CALCULATE(SUM(Hours[HoursPerDay]);FILTER(Hours;Hours[StartDate] <= VALUES('Calendar'[Date]) && Hours[EndDate] >= VALUES('Calendar'[Date])))
This is the important bit because it checks if it should include the hours for a prject on that day.
When putting this in a stacked column graph, you need to place the HoursPerProject in the value and the Date of calendar on the Axis. Hope this helps you.

Calculate Daily Average Month To Date in PowerBI

In Power Bi my average matters per day is not stopping on the current day.
Avg Per Day = DIVIDE([Matters],SUM(Dates[IsWorkday]))
where IsWorkday = IF(ISBLANK(Dates[Holiday]),IF(Dates[DayOfWeekNumber]>1&&Dates[DayOfWeekNumber]<7,1,0),0)
and Matters = COUNT(BillingData[Item])
So today is the 27th of the month so 18 of 20 work days are completed for the
month. So need [matters]/18, not [matters]/20.
How do I factor that in to my average and not affect previous months.
Any help appreciated.
Sounds like you need to just add one more condition to your if statement to add in that the date is less than todays date. Check out this post. I think it might have the solution to your problem or at least give you the idea you need to solve the issue.
https://community.powerbi.com/t5/Desktop/Networkdays-DAX-function/td-p/38044

Leave calculation mistake odoo

Hi i want to calculate half day leave for an employee. when applying for leave, the duration is set as 1/05/2018 18:30 -1/05/2018 23:30. ie 1.00pm to 6.00pm (ist).the day's calculation shows as 0.5 days. Working hour is scheduled as 9.00-18.00. But when generating payslip for the same employee total working days is shown as 31 days and working hours as 279. Odoo does not calculate the half day leave. how can i fix this? i have a doubt about specifying the time in duration while applying for leave. is it should be converted to utc?