Previous year up to a certain date

  Рет қаралды 50,496

SQLBI

SQLBI

Күн бұрын

Пікірлер: 72
@Grundraak
@Grundraak 8 ай бұрын
Alberto Ferrari, you are a master, i have been trying to create custom period selected dates with a slicer to compare a selected year to a previous year. Your video sorted my problem quicksticks, FORZA FERRARI, i am staring at the results in the visual stunned and amazed. Thank You.😃😃
@Milhouse77BS
@Milhouse77BS 3 жыл бұрын
I love the combination of a simple calculated column, and a simple DAX instead of complicated DAX only.
@michaelmusora6942
@michaelmusora6942 8 ай бұрын
The man is a legend
@excelisfun
@excelisfun 3 жыл бұрын
Thank you very much for this elegant solution!!!!!!!!
@jameszhou162
@jameszhou162 3 жыл бұрын
i have been looking for the solution for exact comparison for a while now.. this is simply brilliant. thanks Master Ferrari!
@khardu
@khardu 3 жыл бұрын
Thank you Alberto for another short and sweet DAX Dose.
@bhuprakashsharma6577
@bhuprakashsharma6577 2 жыл бұрын
I was looking this solution for so long. Now I got that. Thanks a lot for making this vidio. Really helpful.
@stephencross4978
@stephencross4978 Жыл бұрын
Thank you, I have been searching for this solution for 2 days now.
@mbianalytics
@mbianalytics 3 жыл бұрын
This is exactly what I was looking for. Thanks a lot for sharing
@HeliSal700
@HeliSal700 3 жыл бұрын
Thank you for this little trick. I use to add Index columns in my date table, which calculates the "distance" between the actual date (This can be any date, e.g. the last date with Sales, or NOW() ), to each row in the date table by day, month, years, etc. This way I can solve a multitude of situations with little effort. Moreover, I add a column with the last date of the actual month for each date. This helps me in a lot of situation as well. I remove these columns if I don't need it.
@chenjoya7792
@chenjoya7792 Ай бұрын
oh man i needed this so hard!
@MeirbhinOConaill
@MeirbhinOConaill 3 жыл бұрын
Great example! I've used % of year sell days complete this, but your example will be more preformant. There is an edge case where the 5th Sep this year is work day 5, while last year was Sep work day 3. This is why I went with % but your solution is very elegant
@SQLBI
@SQLBI 3 жыл бұрын
You can find more complete (and more complex) examples of these comparisons in patterns at www.daxpatterns.com/time-patterns/
@MeirbhinOConaill
@MeirbhinOConaill 3 жыл бұрын
@@SQLBI thank you so much for the continued dedication of the development of BI. The naming conventions and calculation examples that link from this are truly fantastic
@cezaryczajka9198
@cezaryczajka9198 3 жыл бұрын
Super, Great tip. Please suggest how to write a formula that will calculate and show in similar ways, but sales accumulated in the current year and in the column next to it in the previous year?
@lukaszk4388
@lukaszk4388 2 жыл бұрын
hello, simple and clean! thank you!
@trevorbbeairsto
@trevorbbeairsto 2 жыл бұрын
Fantastic - really needed this!
@jasonabbott3874
@jasonabbott3874 2 жыл бұрын
Is this replicatable for more than just PY? E.g. I've been trying to do running totals for 18 vs 19 vs 20 vs 21 (and now vs 22) - I only want to compare each against the current number of days in 22 - would I need a calculated column for each measure to ensure a true/false flag? I'm unsure whether SAMEPERIODLASTYEAR would support what I'm trying to do
@maseratination
@maseratination 3 жыл бұрын
I love this one! I am also going to take your DAX course soon !
@dawnbrelsford8066
@dawnbrelsford8066 3 жыл бұрын
highly worth it, I've purchase all of the DAX. he's definitely one of the better instructors!
@rashenhouse
@rashenhouse Жыл бұрын
respect! thank you😊😊, i spent a lot of time to find this function🙏🙏🙏
@javiermancillavera3072
@javiermancillavera3072 Жыл бұрын
Thanks so much Alberto!
@1yyymmmddd
@1yyymmmddd Жыл бұрын
I wonder how would you do the same thing but with the cut-off date selectable in a slicer?
@stephencross4978
@stephencross4978 Жыл бұрын
I'm stuck on the same issue, if you get a solution, pls let me know and I'll do the same for you
@jayshankarsingh7376
@jayshankarsingh7376 Жыл бұрын
Thank you so much Sir :)
@ZiggyBoon
@ZiggyBoon 3 жыл бұрын
So, the issue I have with this particular approach is that you're putting a calculated column dependent on the fact table (a sales table) into the calendar table, e.g. pulling a summarized value from a "many" table into a "one" table. And I'm wondering if this would be a problem when slicing by, for example, product where different products might not have been sold on that day from the prior year (or may not have existed in the prior year). Question: Would it be better to create that calculated column in the Calendar table using logic exclusively from within the Calendar table by using the TODAY() function and referencing a prior period? For example, logic that looks at the date "today" which might be "day 200" and then looks back to the prior year for the corresponding "day 200". This presumes the presence of a sufficiently built-out Calendar dimension, although Power Query could be used for such a task. Regards!
@SQLBI
@SQLBI 3 жыл бұрын
This is a simple example of the technique. I suggest you look at the following patterns for a more complete coverage of the "fair comparison": www.daxpatterns.com/time-patterns/ --> more complete and flexible than this video www.daxpatterns.com/comparing-different-time-periods/ --> compare different ranges of dates www.daxpatterns.com/like-for-like-comparison/ --> solve the problem of products that were not on sale in the previous period
@Bharath_PBI
@Bharath_PBI 3 жыл бұрын
I had done this but user wanted to have a date selection and make this dynamic, so couldn't use calc column method. Had done it with measure considering the selected date. Can you make a video on that? Thanks again. Enjoying DAX!!
@SQLBI
@SQLBI 3 жыл бұрын
The example in this video is simple and works for just one measure. A more flexible and complete technique (that requires more DAX) is described here: www.daxpatterns.com/standard-time-related-calculations/ However, performance is very good also with the more advanced technique.
@Bharath_PBI
@Bharath_PBI 3 жыл бұрын
@@SQLBI That is amazing. Thank you 👍
@3danim8r1
@3danim8r1 3 жыл бұрын
Simply Great Sir.....
@jessmau
@jessmau 3 жыл бұрын
WOW, I love this! Thanks for sharing. 🙌
@KgasS
@KgasS 2 жыл бұрын
Thanks. Another way is to use page filter with [Sales Amount] >0.
@gayatrilshinde1560
@gayatrilshinde1560 Жыл бұрын
Your Great 👍
@amirhd2080
@amirhd2080 3 жыл бұрын
I was thingking use a filter. But its use DAX. Great way.
@dataghostbi8619
@dataghostbi8619 Жыл бұрын
Hi Sir, Thanks for this great trick, I was searching for a long time. One thing more I want to ask is that this will work for the current year & previous year fine but if we are comparing three or four years' values then how can we get data for such type mean at a particular date for a month in every year.
@MohamedGamal-pj6wd
@MohamedGamal-pj6wd Жыл бұрын
Hi I need to know why you used -12 in the end date function And thanks 👍
@lamlya6908
@lamlya6908 3 жыл бұрын
You are the best
@uyenbui7036
@uyenbui7036 3 жыл бұрын
Its so great. Thank you so much ^^
@akhildharimisetty2767
@akhildharimisetty2767 Ай бұрын
It will be good if you can provide the dataset
@SQLBI
@SQLBI Ай бұрын
You can find the link in the description!
@goldwhispers
@goldwhispers 3 жыл бұрын
what if you only want to calculate it for a specific area? We have sales coming in drips and drabs by area, how would you adjust this to only look at previous year sales against current year sales for a particular area?
@AlanConfrey
@AlanConfrey 9 ай бұрын
How can this be used for multiple years?
@abdulrehman56
@abdulrehman56 2 жыл бұрын
How to have same solution in Power Query @SQLBI
@1yyymmmddd
@1yyymmmddd 3 жыл бұрын
Great stuff ! Thank you.
@mikloshimics7789
@mikloshimics7789 2 жыл бұрын
I see the same results by modifying the measure only. CALCULATE( [Sales Amount], SAMEPERIODLASTYEAR( 'Date'[Date]), 'Date'[Date] < EDATE(MAX('Sales'[Order Date])+1,-12) )
@alexpetkunas9669
@alexpetkunas9669 Жыл бұрын
I'd be interested to see the result of this. When I try it, I get an error saying "A function 'MAX' has been used in a True/False expression that is used as a table filter expression. This is not allowed". Perhaps it has something to do with my choice of visual, but I need to use a matrix visual for my application, so if that's the reason, I'm out of luck. I appreciate you sharing your variation though. Definitely thought it would work for me.
@AliAlSayer
@AliAlSayer 2 жыл бұрын
but what if the last date of month is 30 April i should compare it with 31 of mar at this case as month closure
@sbn4862
@sbn4862 2 жыл бұрын
Can DateYTD ,MTD return correct result if we did not have sales evry day?
@SQLBI
@SQLBI 2 жыл бұрын
Yes, you just need a complete Date table.
@LuisRomaUSA
@LuisRomaUSA 3 жыл бұрын
ha perfect solution to a lot of visuals in my report
@VladMZ
@VladMZ 3 жыл бұрын
Normally, you want to have Date Type calculated in Power Query, as the best practice of data modeling. P/C/F
@IoriYagamiKOF98
@IoriYagamiKOF98 3 жыл бұрын
what will happen with the variable LastSaleDatePY when we have sales for 29th february ? would it return blank ?
@SQLBI
@SQLBI 3 жыл бұрын
In this case it is blank, but the behavior can be controlled in other ways (it also depends on you using DAX standard time intelligence functions or note). Look at the more complete coverage here: www.daxpatterns.com/time-patterns/
@pavlikjanata
@pavlikjanata 3 жыл бұрын
I am little bit surprised by the solution with categorizing previous year as partly "in past" and partly "in future". I see potential confusion in future usage of such a column. I usually solve this by using very similar column but containing a "real" distinction of past and future dates. In your example 9/6/2009 (and all following dates) would be future and 9/5/2009 would be the past. With that when I filter the column with only past dates everything works fine as well because that filters current year until today and hence the same period last year takes only corresponding part of past year too. Am I missing something here? What is the advantage of your approach comparing to one described above? I have to add that I am using that IsPast column to switch between the "adjusted" view and the "full" view of the whole previous year. Both views are used by our users.
@SQLBI
@SQLBI 3 жыл бұрын
this technique is simpler to use in Dax. a more complete and flexible approach that is similar to your description is the column ShowValueForFutureDates in www.daxpatterns.com/standard-time-related-calculations/
@NoShadowOfDoubt1
@NoShadowOfDoubt1 3 жыл бұрын
Great modification, however what is the impact on speed of calculation if the sales and date have 20 years of data?, thanks
@SQLBI
@SQLBI 3 жыл бұрын
There is almost no impact in performance.
@NoShadowOfDoubt1
@NoShadowOfDoubt1 3 жыл бұрын
@@SQLBI Thank you, I wish you a happy & healthy 2021 and many years to come!
@juandavidbohorquezgiraldo3702
@juandavidbohorquezgiraldo3702 3 жыл бұрын
I could do it in the same way but with the closing date of the last month for example if the current date is November 15 that compares me from September 30 of the current year with September 30 of the previous year
@miranikkila9672
@miranikkila9672 Жыл бұрын
What about, when I want to have a cumulative YTD?
@mehdifadhli6413
@mehdifadhli6413 3 жыл бұрын
I like it thank youuuu
@Halamahua
@Halamahua 3 жыл бұрын
Couldn't be done just with the measure? Add an extra argument on the calculate function
@SQLBI
@SQLBI 3 жыл бұрын
Yes, but the cost in performance would be relatively high, especially if you have many years in the Date table.
@Halamahua
@Halamahua 3 жыл бұрын
@@SQLBI cool 😎. Many thanks, keep up the good work!
@siddheshamrutkar8684
@siddheshamrutkar8684 3 жыл бұрын
Hello Sir, Superb calculation.. Was having one doubt is there an performance issue using time intelligence functions.. As I have a requirement to calculate last year sales from current date so is it good idea to calculate the same in the table and then use it in the calculate for filtering purpose..
@SQLBI
@SQLBI 3 жыл бұрын
For more complex issue and more optimized code, look ad Time Intelligence patterns here: www.daxpatterns.com/time-patterns/
@SamFisher-x2y
@SamFisher-x2y 12 күн бұрын
shouldn't the equal "=" sign be removed from Date
@jansjoblom1602
@jansjoblom1602 Жыл бұрын
I tried this on dax and M-language. Needed to have this more dynamic so did it like this =if Date.Month(DateTime.LocalNow()) >= [MonthID] then if Date.Day(DateTime.LocalNow()) > [DayID] or Date.Month(DateTime.LocalNow()) > [MonthID] then true else false else false For me it worked... and same logic worked also on dax calc cols. With this it check backwards every year untills current date
@alexandrab1534
@alexandrab1534 4 ай бұрын
Merci beaucoup !!! C'est ce que je cherchais :) i'm saved
Evaluation of variables in DAX
3:26
SQLBI
Рет қаралды 33 М.
Understanding context transition
18:25
SQLBI
Рет қаралды 71 М.
Happy birthday to you by Secret Vlog
00:12
Secret Vlog
Рет қаралды 6 МЛН
風船をキャッチしろ!🎈 Balloon catch Challenges
00:57
はじめしゃちょー(hajime)
Рет қаралды 75 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 1,1 МЛН
This Year VS Last Year Time Comparisons & Differences In Power BI
9:21
Using ALLEXCEPT vs ALL VALUES
13:35
SQLBI
Рет қаралды 56 М.
Power BI: Hiding future dates for calculations in DAX
12:31
Guy in a Cube
Рет қаралды 48 М.
Top 10 Power BI Features You Should Be Using Right Now!
17:24
How to Power BI
Рет қаралды 90 М.
Power BI Show Year-to-Date (YTD) Across Multiple Years
15:58
Avi Singh - PowerBIPro
Рет қаралды 117 М.
Differences between GROUPBY and SUMMARIZE
28:30
SQLBI
Рет қаралды 40 М.
Me Charging My Phone Before Going Out
0:18
Godfrey Twins
Рет қаралды 6 МЛН
Making iPhone16 pink📱
0:34
Juno Craft 주노 크래프트
Рет қаралды 24 МЛН
Apple phone #shorts #trending #viralvideo
0:48
Tech Zone
Рет қаралды 663 М.
СКОЛЬКО СТОИТ КАЖДЫЙ КОМП APPLE? (Ч.1)
0:37
ТЕСЛЕР
Рет қаралды 182 М.