Quicksight calucalted field /YTD calculations - calculated-field

Sum($(vSetYTD) ResidentDays) this calculated field is doing sum of "residentDays' while setting YTD function(This expression is used in qlik sense/qlikview.)
Now in quicksight how to set a similar YTD function so that if I have given a filter/control of date(Year).My YTD changes automatically to that year.
Example 2021 YTD of sum(residentdays)=80%
after selecting the year as 2020 I get YTD of 2020 year.
Looking for positive response

For Period to date calculations in quicksight: periodToDateSum()
YTD: periodToDateSum(Sales, Order_date, YEAR)
MTD: periodToDateSum(Sales, Order_date, MONTH)

Related

I am trying to get a month and year to date column in SQL

I am trying to create a month and year to date column but the FY starts from October and I need it to roll into the next year so this can automatically update in Power Bi I have the Date ID for our year now maybe need flags to show the current month and current year then I can create a measure in Power Bi, also need it to sum up the months for year to date etc if I click january it shows me sales from October to January.

How to calculate sum of amount for current month including the amount of previous months in Power Bi?

I would like to create DAX expression. This is the condition and I have my month and year table in separate column.
If we choose Month as a March then it should show the sum of amount of Jan, Feb and as well as March. Similarly, If we choose Month as Dec then it should have the sum from Jan to Dec.
How can we write DAX expression for this condition in Power Bi?
You probably need a measure as below. You need to have a separate Date/Calendar table for that which is connected to your Data table using Date column.
total_amount_ytd =
CALCULATE(
SUM(your_table_name[your_amount_column_name]),
DATESYTD(your_date_table_name[your_date_column_name])
)
With this above Measure, if you add Year/Month in a table with the new Measure, you will find the value per year will increase from January to December for a single year and starts re calculating from January again in the next year.

MDX Calculated Measure Year to Date

I have an OLAP multi dimensional cube, which in its simplest form contains:
A fact table with a NetAmount measure
A Time dimension, with fields for Year, Month, Day, Day of Month, Day of Year, etc
The requirement is that the user wants to be able to compare the total NetAmount from the beginning of each year up to a specific date. The date can be chosen by setting filters on the Day and Month fields. For example, the user wants to see total value for:
01 Jan 2019 to 20 Jan 2019
01 Jan 2018 to 20 Jan 2018
01 Jan 2017 to 20 Jan 2017
etc
What would be the best way to tackle this requirement?
You can create calculated member with YTD function like this:
CREATE MEMBER CURRENTCUBE.[Measures].[NetAmountYTD]
as
Aggregate(YTD ([Time].[Time].CurrentMember), [Measures].[NetAmount])
You could also create Utility dimension for example TimeUtility, and add YTD member, and define it like this:
Scope([TimeUtility].[YTD]);
this = Aggregate(YTD ([Time].[Time].CurrentMember), [TimeUtility].[DefaultMember]);
End Scope;
This way whatever measure you look against [TimeUtility].[YTD] it will give you Year to Date for that measure, not just NetAmount, so it will be general solution.

Power BI - Difference between amount per day and total in a table

I have a table with the sales from last 2 years, and I want to compare the sales from this year with the same natural day last year. For example, Sunday 1st of April 2018 will be compared with Sunday 2nd April 2017.
In order to do that I have created the measure
sales_last_year = CALCULATE(Sales[Revenue]); SAMEPERIODLASTYEAR(DATEADD('Calendar'[Date];+1;DAY)))
And I have created another measure where I have the value from the same day last year:
Prueba_sales_last_year = CALCULATE(Sales[Revenue]); SAMEPERIODLASTYEAR('Calendar'[Date]))
The result is the following:
Sales last year
As you can see the sales per day shows 5.316€ and 3.546€, which is correct, but the total is 111.796 €, which is not correct. However, the measure with the formula without the natural day the sum of the two rows is correct. How could I solve this?
Thank you very much in advance
I just changed the order to calculate the date and it was solved.
sales_last_year = CALCULATE(Sales[Revenue]);DATEADD( SAMEPERIODLASTYEAR('Calendar'[Date]);+1;DAY))

create calculated member based on date for condition

I have a Date dimension that I would like to check current month and current year, and then display a different Measure depending on that evaluation.
example:
MM - 04
YY -2016
Calculated member determines current month then for months prior(1-3) it shows measure Qty Shipped. For current month and beyond(4-12) it shows measure Forecast. This logic is only working with current year.
Thanks.
IIF(([02 Dates].[MM].currentmember,[Measures].[Qty Shipped])<
(
STRTOMEMBER('[02 Dates].[MM].&['+format(now(),'yyyy')+']&['+format(now(),'MM')+']')
,[Measures].[Qty Shipped]),
[Measures].[Qty Shipped],
[Measures].[Current Forecast])
Seems to do the Current Month on correctly, but doesn't move qty shipped to months 1-3.
Thanks
Does this logic look correct.
Any help much appreciated.