Computing rolling average in DAX

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024

Комментарии • 150

  • @mathew9665
    @mathew9665 3 года назад +27

    I wish I could understand DAX in such a fluent manner, to be able to quickly throw that type of measure/calculated group together. Pure Joy & art to see someone who is fluent create such a powerful visual

  • @mangeshmehendale4139
    @mangeshmehendale4139 3 года назад +4

    Alberto and Marco - your videos fill me with pure unadulterated joy!

  • @anson7140
    @anson7140 2 года назад +2

    I like the way he explains. It is clear and soothing.

  • @motichoorladdu
    @motichoorladdu 3 года назад +4

    This has been the latest requirement in my organization and I am just getting to creating this calculation group. You just brought sped up my implementation time. Super greatful!!

  • @johan5315
    @johan5315 3 года назад +9

    You make DAX a work of art!

  • @elishaconvery3761
    @elishaconvery3761 Год назад +1

    Sir, I would like to thank you so utterly from the bottom of my heart. I've been unable to use 12M rolling avg in my powerbi as something funky always happened in the background that left me with wonky values.. I've been searching for days, have watched countless videos and help threads and nothing worked. That is, until I came across your fabulous video. It finally worked! Thank you so much!

  • @vijayvizzu1
    @vijayvizzu1 3 года назад +2

    Nobody teaches like you.. you explained the logic, thereafter you applied in the blank model. Even we can't expect this much of explanation in paid courses. Thank for you sharing your knowledge :)

  • @roadtech6472
    @roadtech6472 3 года назад +6

    Amazing! You handle DAX like Einstein used to handle phisics.
    Congrats Alberto! Thanks for sharing knowledge.

  • @ashishmohan4707
    @ashishmohan4707 3 года назад +1

    Hi Alberto,
    You are really amazing & Rockstar in DAX
    after watch your Power BI tutorial I realize DAX is very easy.
    your way of explanation is very very simple and clear .
    Thanks you have been created these very important tutorial all of us.
    Thanks

  • @raqzg2083
    @raqzg2083 2 года назад +2

    Excellent - love how you made the concept easy to understand. What I really like is you explained it with a big picture in mind, and very logical. Thank you for sharing.

  • @cesarebellentani
    @cesarebellentani Год назад +1

    You are always the number one! I find always a solution to my Power BI problems in your videos! and very clear. Thank you

  • @lbarbyery
    @lbarbyery 3 года назад +2

    This is a good case of use and a practical way to use all the flexibility of calc groups of DAX. Thanks to share with us!

  • @michaelazelena9060
    @michaelazelena9060 2 года назад +1

    This is finally a working manual for rolling average. Perfect job!

  • @alohaaloha8437
    @alohaaloha8437 2 года назад +2

    This is so helpful! Alberto always has the best in-depth analyses. Just an interesting observation: the FirstSelectedDay

  • @mounjayansaha4750
    @mounjayansaha4750 3 года назад +1

    Thank you so much. This is the best video I have seen on Running averages.

  • @tiffanyharris711
    @tiffanyharris711 3 года назад +1

    I wish RUclips had a LOVE button! THANK YOU FOR THIS!!!!!

  • @panyaphatthurapra7967
    @panyaphatthurapra7967 2 года назад +1

    Always the best tutorial I could ask to solve my problem. Thank you 🙏🏻

  • @GrabowskiMaciej
    @GrabowskiMaciej Год назад +1

    the best yt channel about dax

  • @alexandreluizrosa9933
    @alexandreluizrosa9933 Год назад

    Thank you so much! I could finish a presentation at work because of your help and expertise. Thank you!

  • @Truth-N-Lies
    @Truth-N-Lies 2 года назад +1

    Matero, Salute to you for your art of teaching DAX

  • @andreeaolah6543
    @andreeaolah6543 3 года назад +2

    Real mastery indeed. Wow!! Love the elegant solution!! Thank you for the awesome () !!

  • @stevenknight5920
    @stevenknight5920 3 года назад +2

    Thanks as always for great content; the high quality explanation and precise communication of the thought process is what I find most powerful.

  • @emilyamalkin4367
    @emilyamalkin4367 Год назад +1

    Amazing! You are the best teacher and a DAX genius! Thank you! ❤

  • @francismastro
    @francismastro 2 года назад +1

    Thank you for this. Very helpful and I love the way you explain how it works.

  • @irfandaud7380
    @irfandaud7380 2 года назад +1

    Quality > Explanation > Clarity > Focus = SQLBI

  • @sbn4862
    @sbn4862 2 года назад +1

    every video takes big pleasure.After reading your book Thanks you 👍👍👍👍👍👍

  • @QuentinBeauquesne-uw8mh
    @QuentinBeauquesne-uw8mh Год назад +1

    Thank you alberto, this is really helpful and very well explained 🙏👏

  • @user-yy9em1gu2g
    @user-yy9em1gu2g Год назад +1

    brilliantly explained

  • @russskinner5715
    @russskinner5715 3 года назад +1

    Excellent video, many thanks. Would love to see a similar video showing best practice for sales comparison to previous periods - year, qtr, month etc.

    • @SQLBI
      @SQLBI  3 года назад

      Watch articles and videos in DAX Patterns - Time Intelligence patterns cover all these calculations: www.daxpatterns.com/time-patterns/

  • @aaronroethe1010
    @aaronroethe1010 3 года назад +1

    Thank you for this amazing content!! This empowers me to provide 10x more value to the company that I work for!

  • @gambu4810
    @gambu4810 2 года назад +2

    You are simply brrrrrrrrriliant!!!

  • @maybinkatongo2568
    @maybinkatongo2568 2 года назад +1

    This is awesome very clearly presentation and explanation

  • @ashleygesty7671
    @ashleygesty7671 3 года назад +1

    Amazing video, struggled with this for so long!

  • @ambarkdi9186
    @ambarkdi9186 3 года назад +1

    Was waiting for this. Heartly thankful to sir..from India 🙏

  • @tomm6269
    @tomm6269 3 года назад

    Thank you Alberto!! This helped me solve my issue that I have been putting off for weeks. Of course you take it to another level completely by adding a Calculation group! Great work. Now to just get Tabular Editor on our approved software so I can dig a little deeper....

  • @sedasert7322
    @sedasert7322 9 месяцев назад

    In my case it worked only after having done some additions to the formula. When I applied the formula you explained I got nothing different than each month's total individually. So I added another variable
    var DatesInRange = FILTER(ALL(DimDate), Date[Date] IN Period), and swapped it with 'Period' in 'Result'. So I could get the desired moving monthly average over past 12 moths. But thanks for the inspiration and fabulous explanation.

  • @ivanak7149
    @ivanak7149 2 месяца назад +1

    hey, I really like your videos. very useful, thanks for sharing 🙂

  • @migmanc
    @migmanc 3 года назад +1

    Excellent, as always. Thanks Alberto!

  • @melissabenito1376
    @melissabenito1376 Год назад +1

    Thank you so much for this video, it was very clear and super helpful! I very happily subscribed to your channel! :D

  • @MrMalorian
    @MrMalorian 3 года назад +2

    Perfect, I was just working on this

  • @arksector
    @arksector 3 года назад +1

    Simple and elegant. Thanks!

  • @tacijjola
    @tacijjola Год назад +1

    Thank you Alberto

  • @julie_chen
    @julie_chen Месяц назад +1

    Love this channel 🎉😂

  • @mohamedkhalid8117
    @mohamedkhalid8117 3 года назад +1

    Very excellent and the explanation is wonderful

  • @goldwhispers
    @goldwhispers 3 года назад +1

    great video, Dax ENJOYED!

  • @antoniogarrido3058
    @antoniogarrido3058 3 года назад +1

    Thanks one more time..! very useful and applicable

  • @Lhen134
    @Lhen134 3 года назад +1

    Great video thanks!

  • @adeelyousafMughalsOnline
    @adeelyousafMughalsOnline 2 года назад +1

    Its really helpful. Thanks for the help.

  • @AccessAnalytic
    @AccessAnalytic 3 года назад +1

    Excellent explanation

  • @BIDataLab
    @BIDataLab 3 года назад +1

    Great content as usual. Thank you for your hard work!

  • @Low-cd1zj
    @Low-cd1zj 3 года назад +2

    Amazing content! Just 1 ques if there is a month slicer, how do I exclude the month slicer and still showing rolling average of 12 month?

  • @NoShadowOfDoubt1
    @NoShadowOfDoubt1 3 года назад +1

    Thank you Alberto!

  • @jaggyjut
    @jaggyjut 2 года назад +1

    Awesome. What if I have a help desk data and instead of sales have to count the tickets per month and them per year?

  • @nikhil1888
    @nikhil1888 Год назад +1

    Thanks Alberto for great video.
    Does Averagex works in Aggregated tables
    I have a 300 Million Fact table. So I am using aggs

  • @3danim8r1
    @3danim8r1 3 года назад +1

    Great teacher...

  • @cristiannievesp
    @cristiannievesp 3 года назад +2

    Thank you ! This really help me on my Work!
    BUT I have only 1 question please!! how to calculate the total of the Rolling average sum ?
    I tried with an If, HASONEVALUE and SUMX but it does not work :(

    • @sahilkothekar9927
      @sahilkothekar9927 2 года назад

      Hi ,have you got any solution for this . Iam also facing same issue

  • @cezaryczajka9198
    @cezaryczajka9198 3 года назад +1

    Great tip! Thanks a lot !!!

  • @reananand2025
    @reananand2025 2 года назад +1

    can you achieve a 3 months rolling average as a calculated column, most examples i have seen is that of calculated measure, would like a demo of the same feature as a calculated column.

  • @sravankumar1767
    @sravankumar1767 3 года назад +1

    Nice Explanation...

  • @tatianamelnikova9780
    @tatianamelnikova9780 3 года назад +1

    Great video Course!!!

  • @ThreadRider
    @ThreadRider Год назад +1

    Hi Alberto, Thanks for all you do for the Power BI community. I have created a Power BI report that uses field parameters in a chart to allow user to select Vol, Sales and Cost. I also created simple moving average, but business wants to include only days where there are sales. I.e. Non-contiguous dates.
    ​For the moving average, I am also using parameter to allow user to select from 5 to 100 days moving average. I can do a simple moving average but having challenges with non-contiguous dates.
    Any tips or assistance you can provide would be greatly appreciated. Thanks

  • @thewarriargaming3663
    @thewarriargaming3663 4 месяца назад

    Thank you this helps lot

  • @davidpearce1583
    @davidpearce1583 11 месяцев назад

    Who knew Frank from Father of the Bride was such a PBI monster?!

  • @angmatvargasbah
    @angmatvargasbah 3 года назад +1

    Hello my friend. I am Angel Vargas. I am from Chile. How can we develop and implement in DAX language the Holt Winter model to project demand, sales and business contribution? Thanks.

  • @itsabigdiehl
    @itsabigdiehl Год назад +1

    This has been so helpful! I do have a question though. What if your "Sales Amount" column had zeros? How would you calculate rolling averages then? I have my data setup just like your example, but for the measures that calculate averages, they are not showing any results if that month's sales amount is zero. Any suggestions?

    • @SQLBI
      @SQLBI  Год назад +2

      Blank are ignored, 0 are not ignored - if you want to ignore them, filter those rows out or modify the measure so that it returns BLANK instead of 0.

  • @jansjoblom1602
    @jansjoblom1602 Месяц назад

    I am able to use this in visuals but in tables Totals are missing for this measure. How could I get it to count also totals in table?

  • @rolandszirmai3922
    @rolandszirmai3922 3 года назад +1

    Ciao Alberto, great video as always. I actually read the original/previous article about Rolling AVG before. I also used it as a starting point for my measure. However, I would like to ask your opinion about something. I would like to show rolling 3 months only from the 4th months in my model. Same with the rolling 6 months, I only want to see the line from the 7th month in my model. *this is also a business requirement. What sort of a best practice would you suggest when it comes to optimizing my DAX? Grazie tanto mille!

    • @SQLBI
      @SQLBI  3 года назад +1

      See the more complete measures in DAX Patterns - Time Intelligence.
      For example: www.daxpatterns.com/standard-time-related-calculations/

  • @NataliyaIgnatova-kr3zp
    @NataliyaIgnatova-kr3zp Год назад +1

    Thank you for the video. I do have a question though, what is the different between 'Date' [Date] and 'Date[Calender Year Month Number] column? Unfortuantely, I cannot see the columns in the Date table and what they imply. Thank you for your prompt.

    • @SQLBI
      @SQLBI  Год назад

      Calendar Year Month Number is a sequential number for every month, whereas Date is the simply the date of the row.

    • @NataliyaIgnatova-kr3zp
      @NataliyaIgnatova-kr3zp Год назад

      @@SQLBI Hi Alberto, many thanks for your reply. The thing is that I am using the DatesInPeriod function for var Period = DATESINPERIOD(Sheet1[rep_date_w_LateB], LASTDATE( Sheet1[rep_date_w_LateB] ),-3,MONTH) however, I receive an error: "A table of multiple values was supplied where a single value is expected." Can you please advise what I am doing wrong?

    • @NataliyaIgnatova-kr3zp
      @NataliyaIgnatova-kr3zp Год назад

      Hi Alberto, actually, I realized it did not work because I returned not the count of rows :). Thank you for your help!

  • @manuprakash1989
    @manuprakash1989 3 года назад +1

    Fantastic 🔥🔥🔥

  • @jorparts
    @jorparts 3 года назад +1

    Very nice!!

  • @mnowako
    @mnowako 3 года назад +1

    Superb 👍 Thank you.

  • @user-nb1lt2xx3n
    @user-nb1lt2xx3n Год назад

    what needs to change in the formula if the same measure is to be used for computing rolling average for departments?

  • @TiltTeamMafia
    @TiltTeamMafia 2 года назад +1

    The best!

  • @millar2255
    @millar2255 7 месяцев назад

    Trying to calculate the 12 month rolling average for a rate (Measure). It doesn't seem to be working and is just returning the same value as the current month's value (not the average of the last 12 months).

  • @aarushisinha8814
    @aarushisinha8814 2 года назад

    It's and amazing video,
    My requirement is that the calculation shouldn't happen for first 5 months.
    Ex: sales starting from Jan 2007
    So I don't want the average to be calculated for Jan-May 2007, and average to start from the month of June 2007.
    How I'll be able to achieve this.
    Any solution will be very helpful
    Thanks

  • @wmfexcel
    @wmfexcel 3 года назад +1

    Thanks for the video! Clearly explained.
    May I know the difference between DATEINPERIOD and DATEADD? Appreciate your advice.

    • @SQLBI
      @SQLBI  3 года назад +1

      The former gets an entire period starting from a single reference date, the latter shift the list of dates provided by the offset requested.
      Look at examples (and videos) on DAX.guide:
      dax.guide/datesinperiod/
      dax.guide/dateadd/

    • @wmfexcel
      @wmfexcel 3 года назад +1

      @@SQLBIthank you so much!

  • @impressive7920
    @impressive7920 10 месяцев назад

    how can i follow u if u dont show the data u are using and the measures previusly created...

  • @padmabayyarapu2629
    @padmabayyarapu2629 3 года назад

    Hi
    Why its doing average for year only. Values function returns all distinct year moths Sales amount and finally does arithmetic mean . The final calculation is for all years average amount. When the context is day wise or month wise its only showing average for year only. Please assist

  • @vincenzorosa6341
    @vincenzorosa6341 3 года назад

    what about this formula? Would it work the same way?
    VAR NumOfMonth = 12
    VAR Period = DATESINPERIOD ( 'Date'[Date], LASTDATE(dDate[Date]), -NumOfMonth, MONTH )
    VAR Result =
    AVERAGEX ( Period,[Revenue]
    )
    VAR LastDateWithSale = MAX ( SalesOrder Date] )
    VAR FirstVisibleDate = MIN ( 'Date'[Date] )
    RETURN
    IF ( FirstVisibleDate

  • @rickyzeng5907
    @rickyzeng5907 2 года назад

    Is there anyway to calculate moving average on Non-Dates values?

  • @Ultramarplogic
    @Ultramarplogic Год назад

    What happens if you have a date table with date hierarchy? i can't make it work with it

  • @SilvanoPaxia
    @SilvanoPaxia 3 года назад +1

    Tu sei un grande Alberto! #madeinitaly

  • @lifeisgreat11
    @lifeisgreat11 Год назад

    At 7:58, the first year starts with the month number, 31, and increased incremental. But why next years started 365, if the number reset, why not started again the days of month?

  • @matheusmascarenhas
    @matheusmascarenhas 2 года назад +1

    At 9:15, I actually want the measure to consider the "empty" data. In my data, I have months with data, and months without. But I'm facing empty months with the same average of the previous month. What I'm missing?
    Example:
    Jan/20: sales = 4, 12m avg = 4
    Feb/20: sales = 1, 12m avg = 2.5
    Mar/20: sales = empty, 12m avg = 2.5 (I wish it was 1.66, i.e. considering the empty value as 0).
    Any guidance?
    Ciao!

    • @matheusmascarenhas
      @matheusmascarenhas 2 года назад

      I did a few tweaks on my own that may help someone:
      1. Changed my "sales" metric, adding an IF statement: IF ( ISBLANK(Sales), 0, Sales).
      It worked to fill every month with blank data in the middle of the data. However, this won't allow me to get rid of the blank data at the end of the data.
      2. Adjusted my date table references
      My date table was considering 3 fact tables and one of them (the least relevant) considered a longer period. I removed it from the reference, so my date table now considers the period I really want to consider (2020-Present).

  • @aarushisinha8814
    @aarushisinha8814 2 года назад

    Could you please create a video where you can explain how to manipulate the date table, like how you created CY 2007 column and how you arranged the month in monthly order, when I try to replicate the same it's getting arranged in alphabetical order
    Please help me

  • @seang2012
    @seang2012 Год назад

    I am using the quickmeasure for the rolling average but cannot figure out how to get the row-by-row average you have there. Only getting the total average. Agh!

  • @sujatarao9913
    @sujatarao9913 2 года назад

    Hey what If we use Datesinperiod inside calculate only ?

  • @devallamahesh989
    @devallamahesh989 2 года назад

    How to caluculate previous year rolling averages

  • @BernatAgulloRosello
    @BernatAgulloRosello 3 года назад +1

    Nice! I always doubt if I need a RemoveFilters('Date') inside calculate. Would it work if year month was not on the visual and it was over year week (for example)?

    • @SQLBI
      @SQLBI  3 года назад +1

      REMOVEFILTERS( Date ) has just that purpose - keep it and it will work also with year week.

    • @BernatAgulloRosello
      @BernatAgulloRosello 3 года назад +1

      @@SQLBI so the code shown would need a REMOVEFILTERS('Date') to work in any visual that doesn't use year week as dimension

  • @sahmedalee
    @sahmedalee 2 года назад

    I have a question... If we use N parameters to get N rolling month, will it be less effecient than creating calculation groups?

  • @yasseryahya4094
    @yasseryahya4094 2 года назад

    @SQL_BI, I wonder how to calculate rolling averages over hours?

  • @nareshpatel1035
    @nareshpatel1035 2 года назад

    Excellent !!😊, just want to know, if some months data are missing in 12M rolling then how we can do the calculations. I mean , suppose for Nov-21, we need the values from Dec-20 to Nov-21 but suppose Jan-21/Feb-21/Mar-31 data is not available then how we can adjust the measure?

  • @adityaupadhyay3242
    @adityaupadhyay3242 3 года назад

    Amazing, I was just working on this. Have couple of questions:
    1) How will the measure vary if we have a slicer selection suppose of customer ?
    2) We have a page level filter of suppose last 2 year of data and the measure should be filtered by this page level filter?

    • @SQLBI
      @SQLBI  3 года назад +1

      1) It just uses those customers.
      2) This could be more challenging because you don't want a cumulative total but more an "extended" year-to-date. You should modify a year-to-date calculation, getting the right starting date (ALLSELECTED could help). You can find custom time intelligence calculations here: www.daxpatterns.com/custom-time-related-calculations/

  • @hientheboss1
    @hientheboss1 4 месяца назад

    This method no longer work due to filter context will pass through all element in data set. I do not know why ? Maybe DAX engine change policy
    By the way just use =Caculate([SaleAmonunt],
    Filter(
    All(Date) ,
    Date[MonthNum] >= CurrentMonth -12 &&
    Date[MonthNum]

  • @mickygonzalesmg
    @mickygonzalesmg 2 года назад

    I did a 7 day version of this and when I enter this DAX code it stops calculating the rolling average after there are no records. For example, if there were no sales on 9/9 and forward you would think the running average would continue for 6 more days but the running average defaults to zero from 9/9 and forward. Anyone had this issue?

  • @juanignacioXI
    @juanignacioXI 2 года назад

    Great explanation Alberto, just one question. You can make this measure dynamic by using parameters, instead of hardcoding NumofMonths?? Thanks in advance.

    • @SQLBI
      @SQLBI  2 года назад

      Yes, you can use a slicer and retrieve that selection by using the measure created by the wizard parameter, or by using SELECTEDVALUE

  • @meghamaniar7556
    @meghamaniar7556 2 года назад

    Hi Sir, can we do rolling with adding any dimension column as a legend? For example here adding Product in legend and distibuting the rolling average for individual product?

  • @jburris6507
    @jburris6507 3 года назад

    In the Sales R12M calculation, I get a result in the totals row, which repeats the last calculated value. How did you hide the Totals result for this column?

  • @kadirkkkk
    @kadirkkkk 2 года назад

    I think there is a problem. If the measure has no value for a specific month then average formula ignores that month, but it have to be calculated as a ZERO. So i revised the averageX formula as;
    values(....
    0+[Sales Amount]
    ....

    • @SQLBI
      @SQLBI  2 года назад +1

      As usual, it depends on the requirements. If no data means 0, your approach is correct. If no data means that business was closed, you might want to ignore it. The average in DAX usually works like the latter, so we kept the same approach, but your approach correctly implements the former requirement.

  • @patrickkinbonso1809
    @patrickkinbonso1809 11 месяцев назад

    Thank you .. pitifully where I work, we have no access to external tools such as Tableau Editor like you do .. and as a result I can't create the calculation group 😕😕

    • @SQLBI
      @SQLBI  10 месяцев назад +1

      The feature should arrive in PBI Desktop soon (after 4 years!)