I am new to Powerbi and needed some help on creating a dax calculation.
Objective: calculate the margin net of labour costs.
I already have a table that contains the margin$(price - cost).
Regarding labour info:
the fixed wage rate is $17.00
During the week the number of hours worked is 9/ per weekday
on saturday the number of hours worked is 8
on sunday the number of hours worked is 6
I want to create a function that tells me the labour cost for a given day and overall labour cost should sum as each day passes.
I figured I should create specific variables in DAX but following that is were I am confused.
How do I dictate to powerbi the hours and rate to apply? any guidance?
|rate:17.00|
|weekdayhours: 9|
|sathours: 8|
|sunhours: 6|
Related
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.
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.
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
Is it possible to SUM on conditions in Power BI?
I have a column that contains the values UK and Italy alongside other columns: employee and hours spent.
I want to make a measure to show total hours spent by an employee in Italy and another to show total hours spent by an employee in UK.
I am having no luck with the DAX language. Can anyone help?
Yes. There are two basic approaches to this.
CALCULATE(SUM(TableName[Hours]), TableName[Country] = "Italy")
or
SUMX(FILTER(TableName, TableName[Country] = "Italy"), TableName[Hours])
I need to develop a system where user can analyse the past sales records and can predict monthly sales for next year. There I am using simple linear regression and get the past monthly sales records of past 5 years and create a line chart.
X= month
y= sales
e.g. I get the sales of month January for 5 years and get the average and plot the graph for 12 months. So how could I give user to predict for monthly sales for next year based on the graph of linear regression equation?
Also I would like to know whether my approach is correct? or are there any efficient ways to do that?
thanks
Welcome to forecasting. Your question doesn't quite belong here (as MBaas points out, stackoverflow is about teh codez), but while you are here you might as well get started with an excellent book, free and online, Rob Hyndman's Forecasting: principles and practice.
https://www.otexts.org/fpp
Once you have a code-related forecasting question, stackoverflow is the place for it! Hyndman even answers an occasional question here.