Forum Discussion

LEC's avatar
LEC
Frequent Visitor
10 years ago

Calculated Columns Errors

I'm unable to find this solution posted elsewhere; apologies if this has already been answered

 

I'm attempting to calculate the "cost per item" up through a certain fiscal week for both 2015 and 2016.

 

I have 6 columns:

  -Fiscal Week

  -Item

  -2015 Sales Dollars

  -2015 Sales Qty

  -2016 Sales Dollars

  -2016 Sales Qty

 

I am looking to compare the cost per item for 2016 to 2015 at this point in time, so I have a filter on fiscal week to be less than or equal to 15. I am attempting to have two calculated columns, 2015 $/qty and 2016 $/qty to determine the cost at this point. In excel I do this by using sumifs to sum the $ and qtys for each item for the current number of available weeks.

 

Does anyone have any advice on how to do this? I am getting the same value for all items, which obviously isn't true.

6 Replies

  • Sean's avatar
    Sean
    Community Champion

    Do you have a Calendar Table? And can you provide a little sample data?

    • LEC's avatar
      LEC
      Frequent Visitor

      Thank you for your help!

       

      I pasted some data below. The reason there are two lines per week per item is that there are two different types. I did not include this column as I am just trying to get the overall cost per item at week 3. (so data from weeks 1-3 for both years).

       

      This is very simple in excel...not sure how to do it in power bi! In my master set of data there are more items and obviously more weeks. A calculated column of sum(2015 dollars)/sum(2015 qty) just does it for the entire set of data.

       

      Thank you!

       

      FWItem2015 Sales Dollars2015 Sales Quantity (Cs)2016 Sales Dollars2016 Sales Quantity (Cs)
      1Apple$421.642$386.382
      1Apple$1,684.028$1,023.055
      1Banana$1,818.6416$1,350.0612
      1Banana$3,159.6322$2,055.9114
      2Apple$346.091$370.492
      2Apple$1,277.967$1,529.648
      2Banana$1,573.9213$1,522.5013
      2Banana$2,979.0320$2,732.2718
      3Apple$400.672$411.082
      3Apple$1,770.679$1,844.399
      3Banana$1,999.0617$1,812.7015
      3Banana$4,307.9428$3,204.4421
      4Apple$532.922  
      4Apple$2,083.9011  
      4Banana$2,197.0919  
      4Banana$4,122.3627  
      • LEC's avatar
        LEC
        Frequent Visitor

        also, I do not have a calendar table, but could obviously create one, maybe using a hierarchy?

         

        I've never needed to do that before when doing SQL dumped into Excel so just a bit confused!

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    I would think a measure in the form of:

     

    2015 Cost Per Item = SUM([2015 Sales Dollars]) / SUM([2015 Sales Qty)
    2016 Cost Per Item = SUM([2016 Sales Dollars]) / SUM([2016 Sales Qty])

    Create a table for [Fiscal Week], [Item] and your two new measures.

     

    Edit: Oh wait, you would probably need a another measure for a running total/average, look at daxpatterns.com for running total/average patterns. Should be able to use them with your two new measures.

    • Sean's avatar
      Sean
      Community Champion

      Also if you do have a calendar table several of the time Intel functions can take as a parameter FY end say eg (6/30)