Amazon Quicksight Time intelligence functions - amazon-quicksight

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.

Related

DAX ignore row context in measure. Calculate for a defined set of dates and show the value for all dates in visual

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?

DateDiff() Function in PowerAutomate: Where is it?

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

DAX Select a date range in the calendar table

I am looking to select the size of the calendar table, filtering everything before or after some date, much like a slicer does.
I am trying to compute the percentage change between prices of equity indexes between two dates: now and a year ago. The problem is that the same date last year sometimes falls on a non-trading day. In that case I want the code to select the earliest value available.
In a similar situation, where I use a slicer, I implemented this by using FIRSTNONBLANK and LASTNONBLANK functions. This way, if the slicer is set to a non-trading date the system still works.
I am very much a DAX/Power BI novice, interested in the methodology in DAX as much as addressing the current problem.
Thanks in advance.

SSRS 2012 total of a percentage measure

I have a percentage measure calculated in SSAS tabular and its correct.
But when i use it in a report i face the following problem (in all percentage measures).
the values under male and female (which are subgroup of saudi and non-saudi) are correct but if you look at the total under "Both sexes" it is incorrect,because it shows summation of male and female percentage, where the right thing is it shows the percentage of the saudi or non-saudi.
If i calculate the measure in SSRS in the expression fields i get it right as follows
But i want to use the measure to show the right values.
So.. can anyone help me with this i have serious issues in later reports and i just cant simply recalculate the SSAS measures in SSRS using expressions.
Note: dont mind the decimal places differences between the two pics.
Thank you.
You can change your MDX query in SSRS to return the subtotal rows then change your Textbox formulas in the body of the Report to say =Aggregate instead of =Sum. This process is described more here by Stacia. You can use manual MDX queries. Don't miss the comment at the bottom:
Romuald Coutaud March 17, 2011 at 7:52 pm Hi Stacia,
In fact, it works in query mode too in 2008R2. But, I have to admit
that the way that RS and AS work together when you want to use
aggregate function is very difficult to perfectly understand and I
have struggle very long time to make one sample report running in this
way. In query mode you need to write MDX by referencing each level of
the hierarchies from the top one to the deepest one want to display in
your report, even you don’t need to use all these ones. As an example
you have to put Year, Quarter and Month to be sure to display Month
and be able to use aggregate function.
Basically in your report =Aggregate will try to retrieve a row where Nationality is not null and Gender is null. If you get stuck please write back with the list of each field used in each group in SSRS and a screenshot of the MDX query designer.

Calculate Value For Dates Between

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.

Resources