sql-bi / DaxDateTemplate

Power BI template to create a Date table in DAX
MIT License
267 stars 76 forks source link

LastYear #24

Closed tasaab closed 5 years ago

tasaab commented 5 years ago

I did read the "Future Year" comment, but continue to have a question. I to would like to change the LastYear to be in the future, however I'm a novice as well and don't know which part of the parameter to change. Also would like to make sure that regardless of anything else, the LastYear indicated is through 12/31/xxxx or the last fiscal day. Don't really care which one, but if I indicate the last year is 2021, then I would like 12/31/2021 or 6/30/2022. Seems right now the last line for the current year is random and showing as 11/29/2019 before I change anything.

Var TodayReference = VAR CurrentDate = TODAY() Return Date(Year(CurrentDate)+2,Month(CurrentDate),DAY(CurrentDate)) VAR LastYear = YEAR ( TodayReference )

marcosqlbi commented 5 years ago

Are you sure you are sorting data in the data view when you check what is the last day visible? Dates are not necessarily displayed in a sorted way by default in the data view.

tasaab commented 5 years ago

Hello Marco, and a VERY BIG thanks for replying to me. When looking at the table view, NO!!!!! I'm not looking at the table view in a sorted manner, so that is probably why I'm assuming that something was missing. I looked down the table date column and it was in order starting from the indicates start year 1/1. And at the point the sequential progression stopped I assumed the next line was the start of the holiday rows, which I thought were created at the end.

So, not worried about when the table ends.

However, in the LastYear section, how do I adjust that to make sure I'm generating date lines that go outwards in time. For example, if I want LastYear to be 2022. Or is that not how it works. Is it such that the LastYear is always the current year, meaning if I'm in 2021 physically, it always goes through 12/31 of the year (or 6/30 of the following year for fiscal year)? If that's the case, then I'm asking a moot question, I assumed LastYear was changeable to out periods, but if that's not necessary, let me know. For my purposes, if I'm getting through 12/31 in the current year (even if through 6/30 of the following year for fiscal), as long as the definition of current year (today) changes as time goes on, I'm fine. E.g. run today, I have 12/31/2019 as last day of calendar year. Run it a year from now, I have 12/31/2020 as last cal day, that is what I need. Is that how it works?

Thanks again for responding.

On June 15, 2019 at 11:59 AM Marco Russo notifications@github.com wrote:

Are you sure you are sorting data in the data view when you check what is the last day visible? Dates are not necessarily displayed in a sorted way by default in the data view.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/sql-bi/DaxDateTemplate/issues/24?email_source=notifications&email_token=AMLT36R2HUXUPYASFIXPX7LP2UGVPA5CNFSM4HYO7HG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXY24XY#issuecomment-502378079 , or mute the thread https://github.com/notifications/unsubscribe-auth/AMLT36XQJDLNPCCZY6RE6I3P2UGVPANCNFSM4HYO7HGQ .
marcosqlbi commented 5 years ago

To be honest, I don't understand exactly what is the problem you have. The LastYear variable defines what is the last year. The CalendarRange variable defines how to compute the boundaries of one year (Calendar, FiscalGregorian, or FiscalWeekly) It just works, I don't see the problem you are describing.

tasaab commented 5 years ago

Yes, apologies for being confusing. I need the last date to be 12/31/2023 to do predictive analytics

Current Code stops at 12/31/2019:

VAR TodayReference = TODAY () -- Change this if you need to use another date as a reference "current" day VAR FirstYear = 2018 VAR LastYear = YEAR ( TodayReference )

what do I change to make the last date extend to 12/31/2023 ?

On June 15, 2019 at 3:10 PM Marco Russo notifications@github.com wrote:

To be honest, I don't understand exactly what is the problem you have.
The LastYear variable defines what is the last year.
The CalendarRange variable defines how to compute the boundaries of one year (Calendar, FiscalGregorian, or FiscalWeekly)
It just works, I don't see the problem you are describing.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/sql-bi/DaxDateTemplate/issues/24?email_source=notifications&email_token=AMLT36VAYZDT4G2DXGV7SA3P2U5DHA5CNFSM4HYO7HG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXY6KBY#issuecomment-502392071 , or mute the thread https://github.com/notifications/unsubscribe-auth/AMLT36VWUSCGXETDQASH2PDP2U5DHANCNFSM4HYO7HGQ .
marcosqlbi commented 5 years ago

Use: VAR LastYear = 2023

tasaab commented 5 years ago

Thank you very much Marco. Worked well. Last question, to import the date table into a currently existing template, what is the procedure?

Many thanks again.

On June 15, 2019 at 9:06 PM Marco Russo notifications@github.com wrote:

Use:
VAR LastYear = 2023

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/sql-bi/DaxDateTemplate/issues/24?email_source=notifications&email_token=AMLT36X67PXU7CFUS4PJ3VDP2WGYNA5CNFSM4HYO7HG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXZC36Q#issuecomment-502410746 , or mute the thread https://github.com/notifications/unsubscribe-auth/AMLT36TQ5CJRUZ7LBAISTJLP2WGYNANCNFSM4HYO7HGQ .
tasaab commented 5 years ago

Hi Marco, I did figure out how to use the table in a previously existing pbix. Need nothing else and I thank you very much for your help.

Todd.

On June 15, 2019 at 9:06 PM Marco Russo notifications@github.com wrote:

Use:
VAR LastYear = 2023

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/sql-bi/DaxDateTemplate/issues/24?email_source=notifications&email_token=AMLT36X67PXU7CFUS4PJ3VDP2WGYNA5CNFSM4HYO7HG2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXZC36Q#issuecomment-502410746 , or mute the thread https://github.com/notifications/unsubscribe-auth/AMLT36TQ5CJRUZ7LBAISTJLP2WGYNANCNFSM4HYO7HGQ .