Power BI: How to Group by 7 Days Bin for Bar Chart to start from Monday instead of Sunday? - powerbi-desktop

I'm trying to create a barchart showing counts of events with Month View drilling down to Week and to days. I have created new groups, such as column "Month" by grouping 1 month in a bin and column "Week" by group 7 days in a bin. I noticed that when I drill down to week, it always starts on a Sunday. My client wanted to be on Monday. I've tried adding a new column "Week2" with "WeeK" dates + 1. The time axis does shows the date shifted by 1 but the data under that week still starts on Sunday. Attached is a screenshot of my barchart with group by week on Date.
Is it possible to change the Weekly Bar chart to start on Monday instead of Sunday for the drill down?

I can see two possible solution to your problem:
You could quickly create a small table to link to the day of the week you currently have on your table. Then on this table which would have the seven vaules for each day of the week you add a column with your prefered ordering (such as monday first) and then use the "Sort by column" option on the column tools in the top ribbon.
You could use a time dimension table, such as the one found here, you can specify in the script when the week starts, and you can remove all the columns you won't use.
I can't test your exact scenario at the moment, I hope one of these solution may work for you

Related

Calculation of the absence rate per employee

The goal is to use Dax and Power Pivot to determine what the absentee rate per employee is. This lowest granularity can be used later to determine the average absence per area.
I get from the team leaders an overview (Excel), which is shown per day, whether the employee was there on the day or sick or on vacation
tblOverview
Date - Name - State - Area - Shift
Date: Date from 01.01.- 31.12.
Name: Name of the person
State: A = present, E = absent
Area: area
Shift: Week shift or weekend shift (Mo + tue day off)
Since the employees have different shift models, this is probably a somewhat more difficult task. Most work from Monday to Friday. However, some work from Wednesday to Sunday.
Somehow I have to find out how many working days each employee has per week / month and how many days he has been absent. Only how best?
Can this be elegantly solved using a Dax function without adjusting the structure of the table?
I am happy about every contribution!
Edit:
The first pivot table shows how many days every employe have worked ("A") per week.
The second pivot table shows the absence days ("E"):
enter image description here
The result should be shown in the same structure.
First, the function should compare if the day for each employee is a working day in comparison to the shift model (either mo-fri or wed-sun) and then if the employee is off ("E"). If the employee is off, the availability should be 0% or the absence 100% for the respective day.
Here you have an example table/ file:
enter link description here

Spotfire Bargraph to show Avg Quality by year for previous years and by month for current year

I have a bargraph which shows the quality of my data for each month. As the data is growing over the years, the graph is getting messy. So, i would like to show Avg Quality by year for all those months in Previous years but monthly for the current year.
Can any one help me how to achieve this.
Thanks,
-Dileep
This needs to be separated into two charts, or it just won't be legible. I'd suggest:
Creating an AVG by Year bar chart graph for all your data
Creating a details visualization of the above Yearly Average data which shows the 12 months of that year with SUM() as your aggregation method. Be sure to have YEAR > Month on your category axis
Thus, if you need to compare 1, 2, 3 or all the years by month you can select them all, or just the ones you want.
I was able to do it with the help of some calculated columns. To help explain, let's assume the value column in your data set is called Value and the date column in your data set is called ValueDate. I created some fictional data that extends into April, 2017 to help illustrate the solution.
Insert a calculated column to classify whether or not the date in each row is in the current year or not. I'm going to call the column DateGrouping.
CASE WHEN Year(DateTimeNow())=Year([ValueDate]) THEN "Monthly" WHEN Year(DateTimeNow())>Year([ValueDate]) THEN "Yearly" END AS [DateGrouping]
Insert a calculated column that tells us the last date of the month for ValueDate. E.g., if the date in the row is 4/10/2015, the last day of the month for the day in that row is 4/30/2015. If the date in the row is 7/8/2013, the last day of the month for the date in that row is 7/31/2013. We'll call this column LastDateOfMonth.
DateAdd("day",-1,date(Year([ValueDate]),Month(DateAdd("month",1,[ValueDate])),1))
Insert a calculated column that tells us the last date of the year for ValueDate. Of course, it's just Dec. 31 of ValueDate's year. Call this column LastDateOfYear.
Date(Year([ValueDate]),12,31)
Finally, we utilize the previous three calculated columns to add a calculated column for the date value we want to plot. You are wanting to plot by month for the current year, and by year for prior years.
CASE [DateGrouping] WHEN "Monthly" THEN [LastDayOfMonth] WHEN "Yearly" THEN [LastDateOfYear] END
On my value axis is the Value column, which I'm aggregating as an Average. On my category axis is the calculated DatePlot column -- I set the category axis to Categorical Scale. And I'm coloring by the calculated DateGrouping column to offer a visual cue that the data is aggregated differently over time.
Now, should this be done? There are certainly some pitfalls. You can't make the category axis Continuous Scale or else you'll see all the empty months when we're lumping prior years into Dec. 31. On the other hand, gaps are good visually when there is no data for a given period. So I don't know. But I pictured what you were asking and decided to try it. Buyer beware!

display/merge multiple columns in a table as one column just separated by lines

Is there a way to display/merge multiple columns in a table as one column just separated by lines. More specifically, what I want is to display value for rows for different days of the week, and there are multiple such weeks in a year.
Thus, for example, an engineer works on the week on 4th jan '16 from monday to sunday for some number of hours each day, then next week of Jnauary he works some different hours each day.
Thus, every week from Mon to Sun will have a different value for each day. I want to display these weekdays as a cluster so I see them together and not separate columns for every day.
I have attached a sample sheet.
Sample Image

Creating bar graph of event occurrences for each month of several years in excel

I have a long list of dates (about 2000) in an excel spreadsheet and I want to see how many of these dates lie within particular years (and roughly which part of the year also if possible). I know how to make basic graphs in excel, but I'm not sure how to make a bar graph that uses dates. Any suggestions?
I can obviously split events in day, month, and year and then use count to count the amount of each year, but this would not show the placement of the event within the year in the final graph.
20/03/2000
2/04/2000
3/04/2000
26/05/2000
7/06/2000
20/06/2000
22/06/2000
10/07/2000
12/07/2000
22/07/2000
2/08/2000
8/08/2000
11/08/2000
14/08/2000
15/08/2000
12/09/2000
15/09/2000
20/09/2000
25/09/2000
2/10/2000
22/10/2000
24/10/2000
25/10/2000
27/10/2000
1/11/2000
10/11/2000
13/11/2000
16/11/2000
18/11/2000
20/11/2000
25/11/2000
27/11/2000
3/12/2000
6/12/2000
20/12/2000
21/12/2000
22/12/2000
4/01/2001
7/01/2001
11/01/2001
24/01/2001
25/01/2001
2/02/2001
4/02/2001
9/02/2001
12/02/2001
13/02/2001
20/02/2001
21/02/2001
2/03/2001
11/04/2001
19/04/2001
20/04/2001
21/04/2001
24/04/2001
27/04/2001
28/04/2001
2/05/2001
3/05/2001
5/05/2001
12/05/2001
13/06/2001
20/06/2001
25/06/2001
3/07/2001
5/07/2001
18/07/2001
20/07/2001
21/07/2001
22/07/2001
25/07/2001
4/08/2001
5/08/2001
9/08/2001
10/08/2001
11/08/2001
12/08/2001
13/08/2001
31/08/2001
11/09/2001
12/09/2001
17/09/2001
3/10/2001
10/10/2001
18/10/2001
21/10/2001
23/10/2001
4/11/2001
5/11/2001
17/11/2001
22/11/2001
23/11/2001
27/11/2001
29/11/2001
3/12/2001
I cannot check this in earlier versions of Excel, but in Excel 2016, if you build a Pivot Table with your data and drop the date in the Rows - you get your data grouped in Years, Quarters, and Months. If you also drop the date into Values, then you get the Count of values in each year, quarter, and month.
Then a pivot chart looks like this ...
A less magical way to do it
Applies to Excel 2013 and up
From your single column of dates, build a pivot table.
Put the date in Rows. Put Count of date in Values.
Select any one of the dates. Right Click and choose "Group...", or choose "Group Selection" from the Analyze ribbon.
Click on each of Months, Quarters, and Years.
Filter how you would like.
Select PivotChart from the Analyze Ribbon.
You can create a scatter graph as suggested in the comment. Consider your data set and see if there is any other quality that could be added to the chart, which could be plotted on the value axis. For example the number of people attending the event, or the duration of the event in seconds, or something like that, so that the graph contains more information. In the following screenshot, the blue dots are just the 1's from column B plotted on the time line. The orange dots plot another data aspect on the vertical axis.
If you create a pivot table of the dates and drag the date into the Sums area you will get a count of each day, make sure this is sorted. Then a chart will show the number of records for each day. You will need to copy and past values from the pivot to a new sheet to be able to make a scatter diagram from the output of the pivot table (in Excel 2010). But once it is a scatter diagram the events will be in the "correct" places.
If you wanted to group it by month instead you could use a formula to create a column of year & month and then do the pivot and chart on that column. For example the formula below will give you 201605 for May 2016.
=YEAR(A2)&RIGHT(100+MONTH(A2),2)
Weeks would be a bit trickier, but I suppose you could divide the date by seven and then INT it to get a 7 day grouping. These wont show the actual events occurance within the period but would let you see which periods have the most events.If you are looking for things like more events at the beginning of the month or something you might need to try different "groupings" like weekly.

How to get my graph in excel to only start on Sunday

I currently have a spreadsheet that has hourly demand data for an entire year. There are monthly tabs, and within each of these is weekly data. I type in the number of the week I want to view and the column only shows data for that week. I need to find a way to get make a line graph that always starts at day number 1 (Sunday), regardless of when the week starts relative to the first day of the month. For example, week 1 for some months begins with day 6 (Friday) of the week. I want to have a graph that starts at day 6, with nothing before, and has week 2 show a full week's worth of data. The last week of the month would likely cut off before the full seven days.
tl;dr: I need a graph that only starts on Sundays.
Following the scheme:
Add the formulas:
E4 -> =WEEKDAY(A4)
E5 -> =ROW(A4)+(7-E4)
G5 -> =INDEX($A$1:$A$17;$E$5+ROW(I1)-1) ' Autocomplete
H5 -> =INDEX($B$1:$B$17;$E$5+ROW(I1)-1) ' Autocomplete
Graph Source -> =G$4:$H$11
The formulas check the first day of the table (A4), find the weekday (E4), find Sunday (E5) and generate the portion of the table in G4:H11. Only one week ...
In the same way you can add week or check the end of the mounth.

Resources