Forum Discussion

Greg_Deckler's avatar
Greg_Deckler
Community Champion
10 years ago
Solved

Simple Linear Regression with DAX

OK, related to forecasting, I went ahead and followed my own advice and built out a forecasting model in DAX using simple linear regression. Probably can be improved but here is how I did it:   CSV...
  • Greg_Deckler's avatar
    Greg_Deckler
    10 years ago

    In theory, I believe that you could use any filtering mechanism you wanted, you would not have to use ALL. The issue is that if you don't use some sort of aggregation function like SUMX and try to just use SUM, the process will not work because when you place those measures into a column formula, they become filtered by the row they are in and it jacks everything up (technical term). So, you HAVE to use some sort of FILTER. I used ALL as an example since I theorized that would be a common requirement to do a linear regression using all available data. 

     

    It is a good thing to call out, I originally tried to just use COUNT and SUM in my measures and was getting a lot of "Not a number" in my Estimate column until I realized that I needed to use COUNTAX and SUMX instead so it is definitely worth noting. Thanks for calling it out.

     

    I think that a logical next step would be to come up with a Simple Rolling Linear Regression Pattern, that would be pretty spiffy. Probably could do that using a combination on the rolling aggregations patterns on daxpatterns.com and this pattern here.