There are few columns in my Spotfire data table with column names (Month-6, Month-5, Month-4, Month-3, Month-2, Month-1).
Explanation: Month-1 is CurrentMonth-1 ie., Feb 2017.
Month-2 is CurrentMonth-2 ie., Jan 2017 respectively. For next month (Apr'17), Month-1 will become Mar 2017 and Month-2 will become Feb 2017.
For the benefit of the users, I am running a 'change column names' transformation on the table using the below case statement.
case
when [%C]="Month-6" then concatenate(Month(dateadd("mm",-6,DateTimeNow()))," ",Year(dateadd("mm",-6,DateTimeNow())))
when [%C]="Month-5" then concatenate(Month(dateadd("mm",-5,DateTimeNow()))," ",Year(dateadd("mm",-5,DateTimeNow())))
when [%C]="Month-4" then concatenate(Month(dateadd("mm",-4,DateTimeNow()))," ",Year(dateadd("mm",-4,DateTimeNow())))
when [%C]="Month-3" then concatenate(Month(dateadd("mm",-3,DateTimeNow()))," ",Year(dateadd("mm",-3,DateTimeNow())))
when [%C]="Month-2" then concatenate(Month(dateadd("mm",-2,DateTimeNow()))," ",Year(dateadd("mm",-2,DateTimeNow())))
when [%C]="Month-1" then concatenate(Month(dateadd("mm",-1,DateTimeNow()))," ",Year(dateadd("mm",-1,DateTimeNow())))
else "" end
I gave a specific order to these columns as how they should appear in the table.Example: Month-6 should start first and end with Month-1.
This works fine for the current month. But, on 1st of next month when the month names change, columns order get disturbed. I have to re-order them manually.
Is there a way I can permanently fix the order of columns?
Thank you!
Related
I have a table that has a series of Columns with data I need to split out. Example below
STATUS#10/16 12:00:00 (CODE)
I've been able to split it easy enough and when I originally tried to set the date on an older dataset it identified it as a date e.g. 16th Oct 2021 However I started to get errors on this date column and trying with different datasets (10/12, 10/13, 10/14) it is not finding the date. I tried the following query code but I'm receiving errors
[STATUS DATE] is split to 10/14, 10/15 etc
#date( Date.Year(DateTime.LocalNow), Date.Month(Text.End([STATUS DATE]), 2), Date.Day(Text.Start([STATUS DATE]),2))
However I'm getting a function error so I tried
Date.From(Date.Day(Text.Start([STATUS DATE]),2) & Date.Month(Text.End([STATUS DATE]),2) & Date.Year(DateTime.LocalNow)
I have also tried to do this from an example column however the query created is looking at the cell value e.g. if 10/14 then 14/10/2021 else if 13/10 then 14/10/2021. This method i feel is prone for error once I include a larger dataset.
Is there anyway I can determine the date value based on mm/dd format? But with year end in mind, make the YYYY be determined by current year unless we move into Jan and then I don't want the Oct, Nov, Dec value showing as 2022.
You don't really show what your original data looks like.
But if it is like:
Source
Then you can use this code in the Add Custom Column dialog:
let
split=Text.SplitAny([STATUS DATE],"#/ "),
mnth = Number.From(split{1}),
dy = Number.From(split{2})
in
#date(Date.Year(DateTime.LocalNow()),mnth,dy)
The Text.SplitAny function lets you input a list of delimiters and the text will split on all of them. So it is relatively simple to extract the month and day values
to create:
Split [STATUS DATE] one more time into [Month] and [Day] column, using the "/" as a separator. Then you don't have to bother with 1 or 2 digit numbers and you can simply use this formula:
#date(Date.Year(DateTime.LocalNow()), [Month], [Day])
DateTime.LocalNow() is a function, so you need to add the brackets.
[Month] and [Day] are numbers already, so you don't need the Date.Month() or Date.Day() functions.
I have an excel data with Date(from Week 50, 2019 to Week 10, 2020), few columns have been added in power bi mainly Week_No, Year and Week Wise (Which is combined result of Year Column & Week_No Column) (WeekWise = 'Page 1'[Year] & "WK" &'Page 1'[Week_No])
For WeekWise Column, sorting has been done by Year.
However, when i put the Line graph, and sort it i get the graph of 2020WK10 in between 2020WK01 and 2020WK02.
Do we have a way where we can put 2020WK10 after 2020WK09?
As seen in the image the week before 2020WK10 is 2020WK1 and not 2020WK01.
Chart sorts it as Text. Hence, the error.
Rename the week numbers in week column in the 01 formats. For that you can add ' before the leading zeros. So, the 2020WK1 will become 2020WK01 and chart will sort it correctly.
I'm having trouble writing code in VBA that would allow me to input any given date then have an output of the current work week. I need a restriction of if the date is Sunday through Tuesday, it will keep that current work week and year but if the date is Wednesday through Saturday, then the next work week and year will show. For example, I'm looking to input (5/28/19) and have an output of 201922 or an input of (5/29/19) with an output of 201923 even though its technically the same work week.
Before getting too in depth, I do have a working function that provides the year and work week, but I'm trying to adapt the function or add a separate function that will change in to the next work week according to the given date.
I'm new to VBA but have tried to do a little research over the last few days. I was thinking that I could somehow have one input of the date then have two outputs where one would be the year and work week then the other would be the number associated with that date (1 for Sunday, 2 for Monday, and so on). I tried to create an if then statement that says if the number associated with that date is 1, 2, or 3 then the workweek would stay the same. If it was any other number then 1 would be added to that work week so it would move to the next one. I'm having trouble with trying to make two outputs and have them connected, if that makes any sense.
This is the code that I tried to create, but continuously failed at making. The function that gives the correct work week (without the adaptation of the work week based on the date weekday) is WWV1
Function WWV2(WeekdayName As Integer)
Dim WWV1 As Integer
If WeekdayName(Date) = 1 Or 2 Or 3 Then WWV1 = WWV1
Else: WWV1 = WWV1 + 1
End Function
This provides the cell with #NUM! when I use the function in that cell, which I assume is because I need to somehow connect the two functions.
how about this:
=YEAR(A1) & TEXT(WEEKNUM(A1,13),"00")
WeekNum returns the weeknumber with 13 saying it starts on Wednesday:
VBA
wkcd = Year(Range("A1")) & Format(Application.WeekNum(Range("A1")),"00")
Outstanding report as of 06 Feb 2013.xls
tbk_report-itm-status_20130207.csv
tbk_report-tscm-status_20130207_0620.csv
TEC Log template 2.1 (February 13).xls
TSOM_SLA_daily_20130207.xls
Data outstanding ticket report as of 6 February 2013.xls
mnr_report-itm-status_20130207.csv
mnr_report-tscm-status_20130207.csv
isd_report-itm-status_20130207.csv
isd_report-tscm-status_20130207.csv
this is the list of file in table at column C
in column A1 I want to search text in column C that contains "tbk" and "tscm"
then in A1 will be like "tbk_report-tscm-status_20130207_0620.csv"
What function should I use?
I know it easy question but I have try mix formula by myself but failed.
You can try
=INDEX(C:C,MATCH("tbk*tscm*",C:C,0))
Note that this will match
tbk_blah-tscm-blah
but not
tscm-blah-tbk-blah
I'd like to create a CALM query to get days and months of any year. Example:
In a list with the results below, I'd like to get all dates that have day equals 10 and month equals 07:
07/10/1984
01/02/2001
05/12/1991
07/10/2007
So, the result would be:
07/10/1984
07/10/2007
I don't think you will be able to do it directly in CAML for any year so you would end up listing out that day and month range for every year - bit of a monster.
Are you able to add extra calculated columns to your list? If so then you can add
DayAndMonth = Day([YourDate]) & "-" & Month([YourDate])
Then its a simple case of filtering using CAML or normal view filter (assuming US date format)
DayAndMonth = "7-10"