I've been doing a lot of Power BI work lately and has been a bit since I've had to construct any Flows. In fact, it was still MS Flow before renamed to PowerAutomate.
Anyways, I could have sworn there was a DateDiff() function which is not there now. So I need a bit of help.
I built a scheduled flow to run every morning on all 'Account' records that calculates the number of days until "Renewal Date". As seen below:
The "Days until Renewal Date" field is an int field and "Renewal Date" is a date field. When attempting to use the following expression for "Days Until Renewal Date," it is not saving to the field in the flow and am assuming that bc this function is no longer valid:
Any advice on this would be helpful.
There is no simple function to calculate the difference between two dates in Power Automate. What you can do instead is
create a variable of type integer called varStartDateTicks for the start date using the ticks() function
ticks(triggerBody()?['StartDate'])
create a variable of type integer called varEndDateTicks for the end date, using the ticks() function
ticks(triggerBody()?['EndDate'])
subtract the two variable values and divide the result by 864000000000
div(sub(variables('varEndDateTicks'),variables('varStartDateTicks')),864000000000)
The result will be the difference between the two dates.
There is now a dateDifference() function added in Power Automate to avoid these complex expressions steps.
Link to dateDifference reference
Related
I am trying to create a measure which calculates the average daily revenue per customer, but only using days in a 6 months period prior to a specific date (where some type of conversion happens).
This specific date can be different for each customer.
The intention is to use the measure as a baseline for indexing daily average in the days/months/years after said conversion date.
If I put my current version of the measure in a card it works just fine (circled in green). But I will eventually have to visualize this over time as well. Thus I need the value to stay the same regardless of the row/date context in a table or timeline (circled in orange).
I suspect I need to use one of the ALL/ALLSELECTED/ALLEXCEPT filter modifiers but I can't really get anything to work.
The measure looks like this for now:
Average daily rev before conversion = CALCULATE (
AVERAGEX(
VALUES('Date'[Date]),
[HI & Acc Rev]
),
FILTER('poc vFact_SalesLine','poc vFact_SalesLine'[OrderDate_ID] IN DATESINPERIOD('Date'[Date],FIRSTNONBLANK('poc vDim_Customer'[DSE first conversion date],1),-6,MONTH)))
I've tried adding REMOVEFILTERS('Date'[Date]) just before the filtering of order dates, but that doesn't work. Gives me the exact same values as shown below.
All help is very welcome? Is my approach all wrong?
This is my first time using amazon quicksight and I am having trouble creating a calculated measure that brings in sales from the year before the one I am evaluating in each row.
Example:
I am looking for the simile to the function CALCULATE (SUM (SALES), PREVIOUSYEAR ()) of PowerBi
I am afraid this is not a complete solution but hopefully it will put you in the right direction.
I started with the following dataset:
In Quicksight, I prepared my data by calculating the Year and Month fields from the Date field of my dataset. I then defined the following calculated field:
lag(sum(SALES), [Month ASC], 1)
I was then able to get the following result:
As mentioned, this is a partial answer as it doesn't work for May 2019 (it should be null/empty instead of 19). It might be easier to work with dates field rather than Month/Year string fields the way I did. I hope this will be of some help.
I have a report that takes sales data from a few tables. I want to add a field that will divide the total sales for the given month by the total number of business days in that same month. Is there a way I can calculate that in an expression? Do I need to create a new table in the database specifically for months and their number of business days? How should I go about this?
Thank you
Intuitively, I would say that you need a simple function and a table.
The table is to host the exceptions like Independence day, labor day, etc.
The function will get two parameters: Month and Year (I'm not providing any sample code since you haven't specified which language you are using).
It will then build a date as yyyy-mm-01 (meaning, first day of the month). If will then loop from 2 to 31 and:
Create a new date by adding the index of the loop to the initial date,
Check if the resulting date is still within the month,
Check if it is a working or not working day (e.g. Sunday),
Check if it is found within the table of exceptions.
If the created date passes all the above tests, you add 1 to the counter.
Though it might look complex, it is not and it will provide you the correct answer regardless of the month (e.g. Feb.) and the year (leap or not).
I have an issue in obiee11g.The function week_of_year() would retrieve week number as 2 for the date '04-01-2016' but should be the first week in 2016.How can i calculate it as first week of 2016 as the requirement is to display this weeknumber.and also all the other week numbers should work fine.Is it abug in obiee11g?
Thanks
You need to create a Time dimension which will calculate and load a Time (or Date) dimension. In Oracle Fusion applications, this is called "Date Leveling". I'm not sure what it's called in the BI Admin tool.
Either that, or add the appropriate logic in BI Answers to offset the Week number appropriately.
A few references:
Microsoft's documentation on DATESBETWEEN.
Somewhat similar question, though the answer and derivatives of the formula don't return the correct results.
Microsoft's documentation on TODAY
Per the above Microsoft documentation, I'm trying to get a calculation for the last three months based on today's current date in SSAS Tabular model. First, I have no idea how to use SSAS and my company doesn't provide any learning material, so I've been reading through the MSDN documentation, which may not be the place to start, so if this is wrong, I'd appreciate being told so. For instance, with C# or Ruby, I can test code in a console to see if I get the result that I want, and I don't see how I can do that in SSAS Data Tools' DAX language - this is a GUI which gives users very little power over what they can do (it took me four hours to figure out how to access a dimension's properties). I am definitely a code monkey.
I tried using the below formula (and derivatives of it) because this is what it looks like Microsoft is doing in their example:
3MonthValue:=CALCULATE(SUM([MeasureOne])/SUM([MeasureTwo]),DATESBETWEEN(DateDimension[Date],DATEADD(DateDimension[Date],-3,MONTH),TODAY()))
The result, nothing. Of course, if I run similar SQL logic, I get the right results. I also used the provided SO example, though I suspect that's not exactly what I'm trying to achieve, and only obtained blanks as answers. Given that I need to calculate a formula between a certain time frame, which in SQL would be the WHERE clause, how do I translate this into DAX? In other words, what is DAX's WHERE and if CALCULATE isn't right, what's the correct approach?
When you say it isn't working, how do you mean? The formula you are using refers to your date dimension's key as the starting date for your DATESBETWEEN function - this means if you are expecting the measure to populate a value, you'll need to be using a particular date in your pivot to establish context.
If you are trying to view the measure at design time, in the editor, there is no context so the measure wont populate.
Moreover, if in a pivot you're looking at a time context that includes more than one date, that also will not work. So say you are looking at a month, or a quarter. Both of these encompass what amount to multiple DateDimension[Date]'s - so again context cannot be established.
so to recap - measures which look at date ranges like DATESBETWEEN using a starting time context that is set to your dimensions time key will only show up in a pivot when the pivots data is filtered to a single date.
You can test this using the same function, but hard set the starting date by replacing DateDimension[Date] with a static date (or possibly TODAY()). The measure should show up in design time because the formula has all the information it needs to complete the calculation.