Forum Discussion

ebrownretail's avatar
ebrownretail
Resolver I
2 years ago
Solved

calculation not working

Hi!

I am trying to pull what my next week forecast is, but the measure is not pulling through any information. Any ideas? As you can see in the screen shot it is summing but not filling in the rows. The sum is correct.

 

Sales Forecast =
(CALCULATE(SUM('Walmart Projection'[Unit Forecast]),
FILTER('Walmart Projection', 'Walmart Projection'[Walmart Week] =
CALCULATE(MAX(Dates[Walmart Week]),FILTER(Dates,Dates[Date] = TODAY())))))

 


 

  • i couldnt get the file to open so that was why i was asking, but i just figured it out. Its because the porgram didnt like i had multiple many to many relationships to the dates table for the walmart week. I changed the one going to my past sales history to a single instead of both relationship and it works and keeps everything else working as well. 

10 Replies

  • MattAllington's avatar
    MattAllington
    Community Champion

    I can't be sure without seeing you data model, but I can tell you that there is a problem with your FILTER statement

     

    FILTER(Dates,Dates[Date] = TODAY())))))

     

    the first parameter Dates inside your filter is already filtered by your visual. It looks like it is the entire Date table, but in fact it is a filtered copy of your date table. The first thing to try is this

     

    FILTER(ALL(Dates),Dates[Date] = TODAY())))))

    • ebrownretail's avatar
      ebrownretail
      Resolver I

      Thanks. I added that and it did not change the issue.

       

      I have a dates table that has 6 digit weeks on them

      I have a projections table with 6 digit weeks

       

      I am trying to get the table to bring back what the next weeks projection is by DC based on the 6 digit week number. Does this help?

  • MattAllington's avatar
    MattAllington
    Community Champion

    I don't know what a 6 digit week is. If you want to successfully use Time Intelligence, there are many rules you must follow. There are different rules if you use a day level calendar and want to leverage in built time intelligence, and if you don't have a day level calendar, and want to write time based calculations. You have t shared any details about your calendar table or the way its joined, so I can't comment. You could read a couple of articles I wrote and I'm sure they will help you. 

    https://exceleratorbi.com.au/dax-time-intelligence-beginners/

     

    https://exceleratorbi.com.au/power-bi-calendar-tables/

     

     

    • ebrownretail's avatar
      ebrownretail
      Resolver I

      the 6 digit week is a year week combination. So this week is 202429 for the Walmart Week. 

  • ebrownretail 

    Do 'Walmart Projection'[Walmart Week] and Dates[Walmart Week] have the same type? I tried to reconstruct your example and it worked fine.

    But at the end i guess you should tell us a little bit more about your data model.

     

    • ebrownretail's avatar
      ebrownretail
      Resolver I

      Hi!

      Yes they are the same. Below are the tables i am using to input the information into Power BI. 

      relationships - 

      • Dates Table Walmart Week to Projections Walmart Week
      • DC List Regional DC number to Projection Regional DC number
      • DC List Regional DC number to DC Inv Regional DC number

      I use a DC listing to get all the information by DC. as you can see below, it will sum the information, but not put it into each row. 

       

      The dates table is just an extended dates table with a walmart week included. 

       

      DC inventory

      distribution_center_numberout_of_stock_case_quantity_this_yearwarehouse_packs_shipped_to_store_this_yearOHOO
      60060000
      60090000
      60100000
      60110000
      60120010
      60160000
      601701120
      60180000
      60190000
      60200000
      60210010

       

      Projections. 

      Regional DCStore NumberWalmart WeekUnit Forecast
      60941212024298
      6068114820242919
      702636202024294
      60662622024292
      6031445120242921
      6036567320242913
      609223392024291
      703954382024293
      6054443620242919
      602721292024294
      606668420242928
      60545102024298
      601633912024296
      703520262024293
      603028852024293
      704528092024298
      6048120420242916
      703934342024293
      6070106020242911
      603832212024292
      604852120242950
      605469982024292
      600937342024291
      • mostho's avatar
        mostho
        Helper II

        as i said i tried to reconstruct a minimal example and it worked.



        maybe you can see on my pbix some difference to yours.