Forum Discussion

GuiBrum's avatar
GuiBrum
Frequent Visitor
6 years ago

Last record before slicer

I have a table with production calculating the cost of each production batch.

Another table showing the sales price of said products.

The visualization should show the average sales price, the average cost and calculate the profit.

When I set the visualization slicer to show 2020 for example, if I sold the material this year but produced last year, the visualization will not find the cost and show 100% profit.

 

table example below:

Production Table  
BatchDateProductCost
1Oct-19A $       0.83
2Oct-19B $       0.88
3Nov-19A $       0.81
4Nov-19B $       0.86
5Dec-19A $       0.82
6Jan-20B $       0.85
7Feb-20B $       0.89
8Mar-20B $       0.83
9Apr-20B $       0.83
10May-20B $       0.90
11Jun-20B $       0.84

 

Sales Table   
DateProductPricethe slicer does not find cost for product AMargin
Dec-19A $       1.18 $       0.82 $       0.36
Jan-20A $       1.20 $           -   $       1.20
Jan-20B $       1.19 $       0.85 $       0.34
Feb-20B $       1.19 $       0.89 $       0.30
Mar-20B $       1.19 $       0.83 $       0.36
Apr-20B $       1.19 $       0.83 $       0.36
Apr-20A $       1.20 $           -   $       1.20
May-20B $       1.19 $       0.90 $       0.29
Jun-20B $       1.19 $       0.84 $       0.35

 

Thank you for any help in this direction

4 Replies

  • GuiBrum , I am not able to figure out the logic you have for price in a month . But I would have created a calculated column to get the price in the sales table. preferably use date in place on the month

    City Name = maxx(FILTER(geography,geography[City Id]=Sales[City Id]),geography[City]) 
    Month Name = LOOKUPVALUE('date'[Month Year],'date'[Date],Sales[Sales Date]) 

     

    You can add remove condition as per need

     

    • GuiBrum's avatar
      GuiBrum
      Frequent Visitor

      Hello, the product price is sales price (for each customer) so it is not calculated.

      the batch cost is calculated within Power Query, the tables are available from power query (it has much more than only the columns I show - these seem to be the relevant columns).

      I tried to be concise on the question. Here is my model

       

    • GuiBrum's avatar
      GuiBrum
      Frequent Visitor

      The month and year on the table are really examples, the actual information is Date.

      The problem is that the date slicer is handling the sales date correctly, but it is not picking up the production cost if the material was made before the slicer cut off.

  • Anonymous's avatar
    Anonymous
    Not applicable

    GuiBrum 

    I see the problem. However, I am confused with your example tables, what i can think of is you may relate the tables by related the batches columns, and then create a slicer with Date column. But I cannot see the relationship and the calendar of your model.

     

    Please provide a sample pbix including the relationship and calendar, so we can test and find a solution for you.


    Paul Zheng _ Community Support Team
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.