Podio Age Calculation - podio

My organisation has a Podio calculation field (see code below) to calculate the age of a person.
In order to get this field to update daily (because we need up to date data), the associated field #Date Today is updated with a Globiflow flow with today's date.
At the moment, there are ~1800 records and growing. So if this is run every day we are going way over the limits set by Globiflow (http://www.globiflow.com/help/globiflow-plans-and-limits.php).
Any ideas on more elegant ways to achieve this without using up our workflows? Essentially I need to calculate the age of each person, each day.
JS in Podio 'Age' field:
var date = #Date Of Birth;
var dateCalc = moment(date);
var currentDate = moment(#Date Today);
var calc = currentDate.diff(dateCalc, 'y','m');
date != null ? calc : null
Thanks
Shaun

One idea is to have an app with single item to keep the today's date. Update this single item everyday using GlobiFlow with today's date.
This item should be referred in all the 1800 Person items. Now use the today date from this single item in age calculation in person app. You can have a GlobiFlow to refer this single item automatically when ever a new Person is created.

Related

Limiting data on monthly basis from start date to system date dynamically in Tibco spotfire

I've tried limiting data on monthly basis in spotfire and it's working fine.
Now I'm trying to do like getting the records from the current date to month start date.
For suppose if the current date is Sept 21, then i should get the records from Sept 21 to Sept-01(dynamically).
I have a property control to input the number of months.
The easiest way to do this is with Month and Year. For example, in your visualization:
Right Click > Properties > Data > Limit Data Using Expressions (Edit)
Then, use this expression:
Month([TheDate]) = Month(DateTimeNow()) and Year([TheDate]) = Year(DateTimeNow())
This will limit the data to only those rows with the current Year/Month combination in your data column. Just replace [TheDate] with whatever your date column name is.
In other places, you can wrap this in an IF statement if you'd like. It's redundant in this case, but sometimes helps with readability.
IF(Month([TheDate]) = Month(DateTimeNow()) and Year([TheDate]) = Year(DateTimeNow()),TRUE,FALSE)
#san - Adding to #scsimon answer. If you would like to precisely limit values between 1st of the current month to current date, you could add the below expression to 'Limit data using expression' section.
[Date]>=date(1&'-'&Month(DateTimeNow())&'-'&year(DateTimeNow())) and [Date]<=DateTimeNow()

Creating a DAX pattern that counts days between a date field and a month value on a chart's x-axis

I am struggling with a DAX pattern to allow me to plot an average duration value on a chart.
Here is the problem: My dataset has a field called dtOpened which is a date value describing when something started, and I want to be able to calculate the duration in days since that date.
I then want to be able to create an average duration since that date over a time period.
It is very easy to do when thinking about the value as it is now, but I want to be able to show a chart that describes what that average value would have been over various time periods on the x-axis (month/quarter/year).
The problem that I am facing is that if I create a calculated column to find the current age (NOW() - [dtOpened]), then it always uses the NOW() function - which is no use for historic time spans. Maybe I need a Measure for this, rather than a calculated column, but I cannot work out how to do it.
I have thought about using LASTDATE (rather than NOW) to work out what the last date would be in the filter context of any single month/quarter/year, but if the current month is only half way through, then it would probably need to consider today's date as the value from which to subtract the dtOpened value.
I would appreciate any help or pointers that you can give me!
It looks like you have a table (let's call it Cases) storing your cases with one record per case with fields like the following:
casename, dtOpened, OpenClosedFlag
You should create a date table with on record per day spanning your date range. The date table will have a month ending date field identifying the last day of the month (same for quarter & year). But this will be a disconnected date table. Don't create a relationship between the Date on the Date table and your case open date.
Then use iterative averagex to average the date differences.
Average Duration (days) :=
CALCULATE (
AVERAGEX ( Cases, MAX ( DateTable[Month Ending] ) - Cases[dtopened] ),
FILTER ( Cases, Cases[OpenClosedFlag] = "Open" ),
FILTER ( Cases, Cases[dtopened] <= MAX ( DateTable[Month Ending] ) )
)
Once you plot the measure against your Month you should see the average values represented correctly. You can do something similar for quarter & year.
You're a genius, Rory; Thanks.
In my example, I had a dtClosed field rather than an Opened/Closed flag, so there was one extra piece of filtering to do to test if the Case was closed at that point in time. So my measure ended up looking like this:
Average Duration:=CALCULATE(
AVERAGEX(CasesOnly, MAX(DT[LastDateM]) - CasesOnly[Owner Opened dtOnly]),
FILTER(CasesOnly, OR(ISBLANK(CasesOnly[Owner Resolution dtOnly]),
CasesOnly[Owner Resolution dtOnly] > MAX(DT[LastDateM]))),
FILTER(CasesOnly, CasesOnly[Owner Opened dtOnly] <= MAX(DT[LastDateM]))
)
And to get the chart, I plotted the DT[Date] field on the x-axis.
Thanks very much again.

Creating a calculated column (not aggregate) that changes value based on context SSAS tabular DAX

Data: I have a single row that represents an annual subscription to a product, it has an overall startDate and endDate, there is also third date which is startdate + 1 month called endDateNew. I also have a non-related date table (called table X).
Output I'm looking for: I need a new column called Categorisation that will return 'New' if the date selected in table X is between startDate and endDateNew and 'Existing' if the date is between startDate and endDate.
Problem: The column seems to evaluate immediately without taking in to account the date context from the non-related date table - I kinda expected this to happen in visual studio (where it assumes the context is all records?) but when previewing in Excel it carries through this same value through.
The bit that is working:I have an aggregate (an active subscriber count) that correctly counts the subscription as active over the months selected in Table X.
The SQL equivalent on an individual date:
case
when '2015-10-01' between startDate and endDateNew then 'New'
when '2015-10-01' < endDate then 'Existing'
end as Category
where the value would be calculated for each date in table X
Thanks!
Ross
Calculated columns are only evaluated at model refresh/process time. This is by design. There is no way to make a calculated column change based on run-time changes in filter context from a pivot table.
Ross,
Calculated columns work differently than Excel. Optimally the value is known when the record is first added to the model.
Your example is kinda similar to a slowly changing dimension .
There are several possible solutions. Here are two and a half:
Full process on the last 32 days of data every time you process the subscriptions table (which may be unacceptably inefficient).
OR
Create a new table 'Subscription scd' with the primary key from the subscriptions table and your single calculated column of 'Subscription Age in Days'. Like an outrigger. This table could be reprocessed more efficiently than reprocessing the subscriptions table, so process the subscriptions table as incrementals only and do a full process on this table for the data within the last 32 days instead.
OR
Decide which measures are interesting within the 'new/existing' context and write explicit measures for them using a dynamic filter on the date column in the measures
eg. Define
'Sum of Sales - New Subscriptions',
'Sum of Sales - Existing Subscriptions',
'Distinct Count of New Subscriptions - Last 28 Days', etc

displaying records with a date at least one day greater then or = to today

I have a field in a table called DATEF. It displays dates as follows: 2013-11-25 08:30:00.000. The field is used to show appointment dates. What I need to show are future appointment dates from today or = to today. (Getdate) for some reason this is not working for me today. Appreciate the help. Thank you.
Try this... you're probably failing to factor in the time component. (This is for SQL Server, you'll have to find the equivalent for your respective environment)
SELECT <SOMETHING>
FROM TABLE
WHERE DATEF >= CONVERT(DATE,GETDATE())

Computing a "sprint" based on the current date

I'm building a PowerPivot/AS data model and I need to convert a date to the appropriate sprint. A sprint is defined as a span of dates (i.e. Sprint N = date range from Date A to Date B). Ideally, I can add this new value as a field in my Date hierarchy. How can I write a DAX formula that will take a date and output the appropriate sprint?
To make things more complicated, in an ideal world different teams can have different dates for a sprint so it would be nice to take the teamId as input and use that to help compute the appropriate sprint name for a given date. NOTE I do have the team/sprint name/sprint start & end dates available for querying
I made a table that looks like the image below and used it with a date dimension table.
I am not sure how you could dynamically calculate the sprint based upon a parameter to indicate the team. This formula would work if you make one column per team in your date table in PowerPivot/Tabular AS.
Team1 Sprint=CALCULATE(
LASTNONBLANK(TeamSprints[SprintName] , 1 ),
FILTER(
TeamSprints,
TeamSprints[SprintName] = CALCULATE(
LASTNONBLANK( TeamSprints[SprintName],1 ),
FILTER(
TeamSprints,
TeamSprints[TeamID] = 1 &&
TeamSprints[StartDT] <= Date[DateKey] && TeamSprints[EndDT] >=Date[DateKey]
)
) &&
TeamSprints[TeamID] = 1
)
)
I figured this out based on Javier Guillen's blog post