I am working on a forecasting graph that will be pulling in data from SQL through power query. The graph will have slicers and filters available to the user to analyze different populations. I am currently being asked to provide a rolling average for each day of the next month but will update daily as more data becomes available. I need 30 days of rolling average that occur after the current date. Using the prior days rolling average calculation. This has to be completed in dax to allow the filters and slicers to work appropriately. The rolling average looks 14 days back.
Any ideas on how to best proceed would be greatly appreciated.
Below is a table of data to show how this looks in excel:
Related
I am trying to create a % of sales measure in power bi. I currently have a visual that is filtered on sales for select items by day and another visual that just has the total sales by day and then I export and do the math in excel. I know there is a way to have just one visual give me the % of sales for the items I have selected, but can't figure out the DAX formula. I am looking for the formula that will take sales for item 1 on Monday of $3,461 and divide by total sales for Monday of $163,534 to get a 2.1% of sales (for all items). Thanks
Power Bi Visuals
I tried a couple formulas but was unsuccessful..
The December release of PBI has been pushed out to all users, and it comes with a brand-new WINDOW function. This allows you to create calculations that would be relative to data being displayed in the visualization rather than applying across an entire table.
Some things you can do with this type of DAX calculation:
Moving averages
Can also combine with parameters for additional functionality!
Dynamic reference lines
Cross row calculations
Finding best and worst performers (with ABS references)
Calculate contributions to the whole
Relevant links:
https://www.youtube.com/watch?v=eib5X5xRlz8
Introducing DAX Window Functions (Part 1) – pbidax (wordpress.com)
WINDOW – DAX Guide
I'm trying to predict (based on simple average) energy consumption untill the end of the month.
I have a table with accumulated energy consumption of my plant until yesterday.
Data Structure in Power Query
'Energy Meter Code', 'Date', 'Hour of the Day', 'Day of the week = Dia Semana', and 'Consumption (MWh)' are the most important columns in this table.
I understand my next step is to:
Create a table with the rest of the days of current month
Calculate average consumption based on different parameters (day of the week, hour of the day, etc) for each hour of the following days
Merge two tables and it's done
However, I don't know how to customize tables in Power Query (syntax problem).
Is there any simple way where I may create dynamic table considering the missing days till the end of the month? Or even better, considering how many hours do we have
Thanks in advance for sharing your experience
I'm using Power Bi desktop to create a sales dashboard, and ran into a small code issue.
I need to calculate average sales in a period of working days, and tried:
TOTALYTD([Sales];
dimCalendar[Date];
dimCalendar[WorkingDays]<=16)
16 is the related working day for 22APR2019 in Brazil.
After that I plan to divide it by a month count or another similar method.
The hard coded 16 works very well, however when I try to use another formula instead:
TOTALYTD([Sales];
dimCalendar[Date];
dimCalendar[WorkingDays]=CALCULATE(MAX(dimCalendar[WorkingDays]);
LASTDATE(dimCalendar[Date])
))
It gives an error that I can't use calculate in a true/false expression.
I tried to use calculated column, but doesn't work as well.
Do you have any idea of how I can create this measure?
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
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