I am trying to highlight today's column -(the header cell)
Date 1
Date 2
Today
Date 4
-
-
Highlight
-
-
-
Highlight
-
-
-
Highlight
-
=A$1=TODAY() is not working
if dates are in row 1 apply to range A1:Z1 this custom formula:
=A$1*1=TODAY()
Related
I am using parameters PeriodType where depending on what will choose will set Dates for DateFrom, DateTo parameters like in the following example:
Period Type (DateFrom, DateTo)
Yesterday - 06/24/2019 - 06/24/2019
Today - 06/25/2019 - 06/25/2019
ThisWeek - 06/24/2019 - 06/30/2019
LastWeek - 06/17/2019 - 06/23/2019
ThisMonth - 06/01/2019 - 06/30/2019
Range - Manually will pick dates from DateFrom and DateTo
When I select for example "This Month" period, DateFrom and DateTo receive dates and Report displays the results.
Result of the selected period
When I select "FromTo" period, my dataset query which generates dates returns null (tried even to return nothing from the procedure) and Date Parameters remain empty and contain calendar icon for choosing dates manually. If I select the dates and run the report, nothing happens and date parameters become blank.
Blank DateFrom and DateTo
Default Values for DateFrom and DateTo is set the same as available values. I even tried to set to No default value but the issue remains the same.
What can I do in this case?
i need to calculate difference between two date excluding sunday. I have table with dates and i need to calculate number of dates of repeated days from last date.
if i have dates like that
27-05-2017
29-05-2017
30-05-2017
I use this code in script
date(max(Date)) as dateMax,
date(min(Date)) as dateMin
And i get min date = 27-05-2017 and max date = 30-05-2017 then i use in expressions
=floor(((dateMax - dateMin)+1)/7)*6 + mod((dateMax - dateMin)+1,7)
+ if(Weekday(dateMin) + mod((dateMax - dateMin)+1,7) < 7, 0, -1)
And get result 3 days. Thats OK, but the problem is if I have next dates:
10-05-2017
11-05-2017
27-05-2017
29-05-2017
30-05-2017
When use previously code I get min date = 10-05-2017 and max date = 30-05-2017 and result 18, but this is not OK.
I need to count only dates from
27-05-2017
29-05-2017
30-05-2017
I need to get max date and go throw loop repeated dates and if have brake to see is that date sunday if yes then step that date and continue to count repeated dates and if i again have break and if not sunday than close loop and remember number of days.
In my case instead of 18 days i need to get 3 days.
Any idea?
I'd recommend you creating a master calendar in the script where you can apply weights or any other rule to your days. Then in your table or app you can just loop through the dates or perform operations and sum their weights (0: if sunday, 1: if not). Let's see an example:
// In this case I'll do a master calendar of the present year
LET vMinDate = Num(MakeDate(year(today()),1,1));
LET vMaxDate = Num(MakeDate(year(today()),12,31));
Calendar_tmp:
LOAD
$(vMinDate) + Iterno() - 1 as Num,
Date($(vMinDate) + Iterno() - 1) as Date_tmp
AUTOGENERATE 1 WHILE $(vMinDate) + Iterno() - 1 <= $(vMaxDate);
Master_Calendar:
LOAD
Date_tmp AS Date,
Week(Date_tmp) as Week,
Year(Date_tmp) as Year,
Capitalize(Month(Date_tmp)) as Month,
Day(Date_tmp) as Day,
WeekDay(Date_tmp) as WeekDay,
if(WeekDay = '7',0,1) as DayWeight //HERE IS WHERE YOU COULD DEFINE A VARIABLE TO DIRECTLY COUNT THE DAY IF IT IS NOT SUNDAY
'T' & ceil(num(Month(Date_tmp))/3) as Quarter,
'T' & ceil(num(Month(Date_tmp))/3) & '-' & right(year(Date_tmp),2) as QuarterYear,
date(monthStart(Date_tmp),'MMMM-YYYY') as MonthYear,
date(monthstart(Date_tmp),'MMM-YY') as MonthYear2
RESIDENT Calendar_tmp
ORDER BY Date_tmp ASC;
DROP Table Calendar_tmp;
I have a requirement to do % of (Workdays till date) / (Total Workdays of the month). How can I create a "Calculated field" for this logic. I don't need to consider holidays or any sort. Any help is highly appreciated.
A quick google search turned up this:
http://kb.tableau.com/articles/knowledgebase/calculating-the-number-of-business-days
In the Calculated Field dialog box, do the following and then click
OK: Name the calculated field. In the example workbook, the calculated
field is named Number of Weekdays. In the formula field, create a
calculated field similar to the following:
DATEDIFF("weekday", [Start Date], [End Date])
- 2 * (DATEPART('week', [End Date]) -DATEPART('week', [Start Date]))
+ (IF DATENAME('weekday',[End Date]) = 'Saturday' OR DATENAME('weekday',[Start Date]) = 'Sunday'
THEN 0 ELSE 1 END)
In your example you take the difference between the first and the last of a month and calculate the working days by subtracting 2 * [number of weeks] for the weekends. Once you have that value you can easily create the ratio you wanted.
I want to get the weeks as columns between two dates in an MDX query.
For example if I input these dates: 2015-01-01 and 2015-02-01 I want to get this:
Week ending January 1,Week ending January 8,Week ending January 15,Week ending January 22
I have created this MDX query with "Filter" method but it doesn't work:
WITH SET [WeeksBetweenDates] AS
Filter([Date].[Year - Week - Date Hierarchy].[Week],
[Date].[Year - Week - Date Hierarchy].CurrentMember.Member_Value >= [Date].[Year - Week - Date Hierarchy].[Week].&[2015-01-01T00:00:00]
AND [Date].[Year - Week - Date Hierarchy].CurrentMember.Member_Value <= [Date].[Year - Week - Date Hierarchy].[Week].&[2015-02-01T00:00:00])
SELECT [WeeksBetweenDates] ON COLUMNS
FROM [Team System]
I get "Unknown" column if I run this query.
You should define dates as subcube slice ({[Date1] : [Date2]}), this will greatly increase query performance + make code more transparent (tested against our TFS):
select
{
[Date].[Week].members
} on 0
from ( select {
[Date].[Date].&[2015-01-01T00:00:00]
:
[Date].[Date].&[2015-02-01T00:00:00]
} on 0
from [Team System])
To make it work through using hierarchy, you should correct
[Date].[Year - Week - Date Hierarchy].[Week].&[2015-01-01T00:00:00] to [Date].[Year - Week - Date Hierarchy].[Date].&[2015-01-01T00:00:00]
I've got the following problem:
i need to convert a datetime field in a where select to a date field.
scope :after_start_date, lambda { |value| where('end_time <= (?)', value) if value}
I need something like where(end_time.to_date + " >= (?)", value)
Is there a nice way to do this?
Update/Example
08.09.2014 14:40 as DB_END_TIME
08.09.2014 AS PARAM_END_TIME
I wanna get all results which until the date 08.09.2014 (including the 8th),
but the comparison where(DB_END_TIME <= PARAM_END_TIME) does not include 08.09.2014
because the PARAM_END_TIME has 00:00:00 as time value.
And i think its not nice to do something like this:
PARAM_END_TIME + 1.day - 1.second - this would work.
So i'd like to convert the database value to the date format in the where statement.
you can use ruby strftime method to create ur own date/time display.
time.strftime( string ) => string
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
%j - Day of the year (001..366)
%m - Month of the year (01..12)
%M - Minute of the hour (00..59)
%p - Meridian indicator (``AM'' or ``PM'')
%S - Second of the minute (00..60)
%U - Week number of the current year,
starting with the first Sunday as the first
day of the first week (00..53)
%W - Week number of the current year,
starting with the first Monday as the first
day of the first week (00..53)
%w - Day of the week (Sunday is 0, 0..6)
%x - Preferred representation for the date alone, no time
%X - Preferred representation for the time alone, no date
%y - Year without a century (00..99)
%Y - Year with century
%Z - Time zone name
%% - Literal ``%'' character
t = Time.now
t.strftime("Printed on %m/%d/%Y") #=> "Printed on 04/09/2003"
t.strftime("at %I:%M%p") #=> "at 08:56AM"
Example:
date = Date.parse('2014-09-08 00:00:00 UTC')
# => Mon, 08 Sep 2014
date.strftime('%d-%m-%Y')
# => "08-09-2014"
And search in database accordingly.. I hope this may helps you
Edit:
If you want to fetch data from your SQL Server and convert datetime to date then have a look at this