I have a line graph in PowerBI and in my date dimension I have the Week Number for every date (note that this is a custom week number with the week starting on Friday).
Whenever I put it on a the x-axis, PowerBI groups all the weeks together, regarless of year... so Week 1 of year 2015 will be grouped together with Week 1 of 2016...
I think to myself: "Ok, no problem, I'll just add the Year after every week number so I'll have 1-2016, 2-2016, and so on."
Well PowerBI sees this concatenation as a string value so when I put that on the graph, it goes
1-2016, 1-2017, 2-2016, 2-2017, 3-2016, 4-2016, and so on....
I've tried sorting the new column by the old week number column, but it does the same thing. Any suggestions on how to accomplish this?
You're on the right track. I recommend a separate (hidden) sort column that sorts alphabetically (i.e. year first, then 2 digit week). In other words, 1-2016 = 201601.
This way, all the weeks for 2016 sort before the weeks for 2017, and the weeks sort in the right order too. (A 1 digit week would mean 20161 will be followed by 201610, which you don't want either.)
Related
So, strange one to explain...
I have a table with the start dates of each person in project (each start day is the first Monday of the week)
I want to know how many people were in the project on any given week.
If I select two weeks in a slicer, for example
Week1
Week3
And there were 10 people in week 1 and 30 in week 3 the total should be 40.
How do I build a measure to do this.
Essentially I'm asking it to count the number of rows(project members) where the start date is >= each selected date and sum each individual result.
I hope this has made sense unable to share much due to work red tape
Thanks
Lloyd
I would do this in the following way:
Create a bin for the work week
Create a measure to count the bin from step 1.
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 have a set of data containing dates that have been sorted out say from 25th June 2016 till 24th August 2016. I have to add a 'Week' column that numbers the starting week from 1 and incrementing by 1 every time a new week comes in that start on a Sunday. I know a little coding but I have no experience with SAS so I am having a lot of trouble with this. The first week would be a little struggle since it could be that the date does not start with a Sunday and I can't simply reiterate the code 7 times. But the week after would not be too hard since it's only doing a loop everytime the date meets with a new Sunday.
I have a lot of things in my mind, I have been googling and tried coding but to no avail. If anyone could explain to me, that would be really helpful.
Try this
data out;
set in;
Week = 1;
if weekday(date) = 1 then Week + 1;
run;
Consider using the built in WEEK function. Find the first week as your base number and then subtract that to get the increment needed. ie if your first week is 5, then
Week_want = week(date) - 5;
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.
Im trying to write function for my logbook in OpenOffice calc.
I have rows that have a date in one of the cells.
Im looking for solution how to calculate rows that have date less than year from today.
I got it working by adding extra cell that calculates days from today, eg.
=DAYS(B7;TODAY())
and then use that field as COUNTIF()reference, as
=COUNTIF(C7:C2177;"<365")
But I would really like to get rid of that extra cell, as its messing up other things in that spreadsheet.
Is there a way to use variables in cell functions, or how could I get this done?
To count all dates between a year ago and a year from now:
=SUMPRODUCT(B7:B2177>TODAY() - 365, B7:B2177<TODAY() + 365)
This is adapted from https://wiki.openoffice.org/wiki/Documentation/How_Tos/Conditional_Counting_and_Summation#Tips_and_Tricks:_Items_Between_Two_Dates.