I created the list of the dates between two dates (minimum and maximum) from another table where i compare the max date and today.
let
first = List.Min(#"Mizan (Banka&Kasa)"[Tarih]),
last = List.Max(
{(List.Max(#"Mizan (Banka&Kasa)"[Tarih])), Date.From(DateTime.LocalNow())}
),
howmanydays = Number.From(last) - Number.From(first) + 1,
Source = List.Dates(first, howmanydays, #duration(1, 0, 0, 0))
in
Source
But I am sure there must be an easier way to achieve this list.
Any ideas ?
Thats pretty much it, unless you prefer to omit howmanydays and use
Source = {Number.From(first) .. Number.From(last)}
then expand and convert format to date
If you want to create a table with the dates of another table maybe the best is:
CREATE NEW TABLE
date = CALENDAR(maxx(table_name, table_name[Date]),TODAY())
table_name is the table you want to select
table_name[Date] is the cell you want to get the last date
Related
I have an issue with a report I am trying to make in SAP. The problem is that I want to only show each SR NUM only once. But there are many appearances in my report. I saw that each number has multiple activities and comments and that is why there are appearing more than once. The thing is that I only need the last appearance based on date for each SR Num and there is no filter that can help me with this. I also tried Ranking but I do not have a metric and created a new variable finding max date for each sr num. That also did not work as there are multi values.
Please help!
For example i have 3 columns sr num, date and comments. The first has 3 different nums but multiple times and the dates are all different as the comments.I need to only keep each sr num once with the most recent date and comment
I created some sample data in a free-hand SQL query which yields this...
You will need to find the maximum date for each SR Num and then only show that row for each SR Num. I used two variables to achieve this.
Var Max Activity Date...
=Max([Activity Date]) In ([SR Num])
Var Is Max Activity Date...
=If([Activity Date] = [Var Max Activity Date]; 1; 0)
Finally add a table filter to only show the rows where the Activity Date is the Max Activity Date for each SR Num.
You do not need the variables in your table in the end. I just put them there in order to visualize what is going on. That's it.
Noel
I have a dataset with an ID column and Edit Date column. There are some duplicate IDs but the Edit Dates will be different for each dupe ID. I created 2 helper columns to help me determine if I need to include the row of data in a separate analysis I'm working on. I included Notes in the sample dataset, with a short description of each column.
I want to include any rows that:
Have Count value = 1
or
Have Count value >1 but the Edit Date value for its corresponding ID is the lowest value of all Edit Dates listed in all rows this value is in
I don't want to include any rows that:
Have Count value >1 and Edit Date value that not the lowest Edit Date for the corresponding ID
So far all I have is the first part...I'm having trouble figuring out how to go about the comparison when Count >1, so any help would be greatly appreciated.
This is all I have so far...
=IF(C2:C=1,"YES",...?)
Thank you in advance!
try:
=ARRAYFORMULA(IF(A2:A="",,VLOOKUP(A2:A&B2:B,
{SORT(A2:A&B2:B, B2:B, 1), IF(COUNTIFS(SORT(A2:A, B2:B, 1), SORT(A2:A, B2:B, 1),
ROW(A2:A), "<="&ROW(A2:A))=1, "yes", "no")}, 2, 0)))
I have a table with a column of values that I would like to update by adding 2.822 of between dates and need help writing this code.
Notes: ColumnName2 adds 2.822 everything, but I want it to add only between the dates. ColumnName1 is the original values column.
It adds 2.822 to all dates, but I only want it to add to what is in between dates, regardless of blank values.
Code:
AddToColumnsBetweenDates =
CALCULATE(SUM(TableName[ColumnName1)+TableName[ColumnName2],
FILTER(TableName,
DATEDIFF(DATE(2 018,01,01), DATE(2018,12,31),DAY
Another one that I tried:
AddToColumnsBetweenDates =
CALCULATE(SUM(TableName[ColumnName1),
FILTER(TableName,
SUM(TableName[Column1])+TableName
[ColumnName2]&&
DATEDIFF(DATE(2018,01,01) < TableName[ColumnName1]=BLANK(),
DATE(2018,12,31),DAY) && TableName[ColumnName1]>=BLANK()))
I figured it out (Add1030ToEachNodeBefore2019 is the 2.822 variable), hence this adds to all the nodes that exist in 2018 only:
AddToNodesBetween2018StartAnd2018End = IF(Table[DateColumn.[Year]=2018, CALCULATE( SUMX(Table, Table[NodeCount]+Table[Add1030ToEachNodeBefore2019]), (DATESBETWEEN(Table[DateColumn].[Date], DATE(2018,01,01), DATE(2018,12,31)))), Table[NodeCount])
I have several records in my database, the table has a column named "weekday" where I store a weekday like "mon" or "fri". Now from the frontend when a user does search the parameters posted to the server are startday and endDay.
Now I would like to retrieve all records between startDay and endDay. We can assume startDay is "mon" and endDay is "sun". I do not currently know how to do this.
Create another table with the names of the days and their corresponding number. Then you'd just need to join up your current table with the days table by name, and then use the numbers in that table to do your queries.
Not exactly practical, but it is possible to convert sun,mon,tue to numbers using MySQL.
Setup a static year and week number like 201610 for the 10th week of this year, then use a combination of DATE_FORMAT with STR_TO_DATE:
DATE_FORMAT(STR_TO_DATE('201610 mon', '%X%V %a'), '%w')
DATE_FORMAT(STR_TO_DATE('201610 sun', '%X%V %a'), '%w')
DATE_FORMAT(STR_TO_DATE('201610 tue', '%X%V %a'), '%w')
These 3 statements will evaluate to 0,1,2 respectively.
The main thing this is doing is converting the %a format (Sun-Sat) to the %w format (0-6)
well i don't know the architecture of your application as i think storing and querying a week day string is not appropriate, but i can tell you a work around this.
make a helper function which return you an array of weekdays in the range i-e
function getWeekDaysArray($startWeekDay, $endWeekDay) {
returns $daysArray['mon','tue','wed'];
}
$daysRangeArray = getWeekDaysArray('mon', 'wed');
now with this array you can query in table
DB::table('TableName')->whereIn('week_day', $daysRangeArray)->get();
Hope this help
I have a table with many anniversaries : Date + Name.
I want to display the next anniversary and the one after with Linq.
How can i build the query ?
I use EF
Thanks
John
Just order by date and then use the .Take(n) functionality
Example with a list of some objects assuming you want to order by Date then Name:
List<Anniversaries> annivDates = GetAnnivDates();
List<Anniversaries> recentAnniv = annivDates.OrderBy(d => d.Date).ThenBy(d => d.Name).Take(2).ToList();
If the anniversaries are stored in regular DateTime structs, they may have the 'wrong' year set (i.e. wedding or birth year). I suggest writing a function which calculates the next date for an anniversary (based on the current day) like:
static DateTime CalcNext(DateTime anniversary) {
DateTime newDate = new DateTime(DateTime.Now.Year, anniversary.Month, anniversary.Day);
if (newDate < DateTime.Now.Date)
newDate = newDate.AddYear(1);
return newDate;
}
Then you proceed with sorting the dates and taking the first two values like described in the other postings:
(from e in anniversaries orderby CalcNext(e.Date) select e).Take(2)