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
Related
I have a promised hours calculation that looks at two dates (Coalesce) and gets the number of weeks in the month and then multiply it by the max promised hours for an employee which has a row for every week of the month. The employee could have 5 rows for every entry a week and the promised hours shows up the same as for example 40 for that week, thus why I have to take the max instead of do a sum. But at the end I need to show the total number of promised hours per week for whatever timeframe is chosen in the date slicer per employee.
Promised Hours Calc = CALCULATE(WEEKNUM(Max([CoalesceActualStart_AbsenceStart]),1)-WEEKNUM(MIN([CoalesceActualStart_AbsenceStart]),1))*MAX(FSLData[PromisedHours])
I then need it to do a sum for every employee on the above calculation.
I am getting all sorts of errors trying to do a sum on the calculation as a whole.
What you write is confusing and incomprehensible. That's why you get the errors. As soon as you are able to formulate your problem in such a way that others can understand it, you will understand it yourself and the errors will go away.
Power Bi gives you the option to look at data by Year, Quarter, Month, and Day. I want the ability to look at data by 7 day periods that start on a specific date (not necessarily Monday or Sunday). How is the best way to accomplish this? I am guessing it will be with a measure but I can't quite figure out what the measure should look like?
Here I know I can assign a day of the week to each row and then use Week Day on my date axis. My problem is I need to be able to put "Tuesday" in the second parameter instead of either 1. Sunday or 2. Monday.
Week Number = WEEKNUM(Sheet1[Date],2)
Thank you in advance!
IIUC, the following might work:
Week number = WEEKNUM(DATEADD([Date],1,DAY),2)
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])))
I've been doing a lot of research on this question over the past few days, but none of the articles I've researched have been able to do. I'm trying to find the difference between two dates in Power BI that excludes weekends, but it also needs to calculate the differences in times as well. All of the articles I've seen have been able to find the difference in the dates themselves, but for my specific problem, the times are important.
For example,
I'm trying to find the difference between Pickup Date/Time and Created Date/Time. The data I am looking at is to find all the shipments that were entered into the system two business days in advance of the pickup date, and those shipments need to be entered in before noon that day.
I've created a Date table that has all dates between 2018-2020 that show whether it's a weekend or a weekday, but I haven't been able to figure out how to basically do Pickup From - Created From and filter out the weekends.
Any help with this would be greatly appreciated.
My data is below that i'm trying to use.
Supplier Lead Times Table with Created/Date Time and Pickup From/Date Time
Lead Time Days
The Lead Time days currently is just ('Supplier Lead Times' [Pickup From Date/Time] - 'Supplier Lead Times'[Created Date/Time]).
Even if I could use the DATEDIFF HOURS function for this, that would work, i'm just having trouble filtering out the weekend days. I have a calendar table that has all the weekdays/weekends
Calendar Week Table
As far as I checked, your "Create Date" and "Pickup Date" fields are always weekdays. Therefore, if we calculate the total difference than put 24 hour back for each weekend, that would work. Try to create a quick measure column like below and apply it to your table:
Difference =
var weekends =
SUMX(
SELECTCOLUMNS(
CALENDAR(min('MyTable'[CreatedDate]), min('MyTable'[PickUpDate])),
"Date", min('MyTable'[CreatedDate]),
"BDay", IF(WEEKDAY([Date],3) >= 5, 1, 0)
),
[BDay]
)
return DATEDIFF(min('MyTable'[CreatedDate]), min('MyTable'[PickUpDate]), HOUR) - weekends*24
I would like to create a calculated column or measure that shows the time elapsed in any given month. Preferably as a percentage.
I need to be able to compare productivity (rolling total) over a month's period between different months.So creating a percentage of time passed in a month would put every month on a level playing field.
Is there a way to do this?
Or is there a better way to compare productivity between 2 months on a rolling basis?
EDIT
I am graphing sales on a cumulative basis. Here is a picture of my graph to demonstrate.[][
Ideally I would like to be able to graph another person's sales on the same graph for a different month to compare.
The problem is each month is different and I don't think power bi allows much customization of the axes.
So I figured a potential solution would be to convert months to percentages of time passed, create two separate graphs and place them on top of each other to show the comparison of sales.
Using percentages doesn't sound right here: one person's "productivity" in February will appear lower than another person's productivity in March just because February has 3 less days.
Just use [Date].[Day].
To answer the original question (even though it shouldn't be used for this), month progress percentage calculated column:
MonthProgress% =
var DaysinMonth = DAY(
IF(
MONTH(MyTable[date]) = 12,
DATE(YEAR(MyTable[date]) + 1,1,1),
DATE(YEAR(MyTable[date]), MONTH(MyTable[date]) + 1, 1)
) - 1
)
return MyTable[date].[Day]/DaysinMonth*100
Also check DAX functions PARALLELPERIOD and DATEADD.
This is the solution I settled on.
I customized the ranges for the x and y axes so they match.
For the y-axis, I simply put the range from 0 to 50+ our highest month.
For the x-axis, I created a column with the DAY function so I got a number assigned to each day of the month which allowed me to manually set the chart range from 0 to 31. I have asked another question on how to only get workdays.