Forum Discussion

Broot's avatar
Broot
New Member
4 years ago
Solved

Dynamic average specific cost calculation

Hi I am trying to create a report for production costs across multiple production units, but I am having issues with calculating average specific costs.   I have cost and production data as two se...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Broot ,

    I created a sample pbix file(see attachment) for you, please check whether that is what you want.

    1. Create a date dimension table(don't create any relationship with other tables)

    2. Apply the date field in the above date dimension table on the slicer

    3. Create a measurea as below to get the special cost

    specific_Cost = 
    VAR _mindate =
        MIN ( 'Date'[Date] )
    VAR _maxdate =
        MAX ( 'Date'[Date] )
    VAR _cost =
        CALCULATE (
            SUM ( 'Cost_Data'[Cost] ),
            FILTER (
                'Cost_Data',
                'Cost_Data'[ts] >= _mindate
                    && 'Cost_Data'[ts] <= _maxdate
            )
        )
    VAR _product =
        CALCULATE (
            SUM ( 'Production'[Production] ),
            FILTER (
                'Production',
                'Production'[ts] >= _mindate
                    && 'Production'[ts] <= _maxdate
            )
        )
    RETURN
        DIVIDE ( _cost, _product )

    Since I don't know what your actual calculation logic is for the Cost/Product field in the Expected Results table, it's possible that the final value returned is not the result you want. Later on, you can update the formula of above measure to get the results you want. Or if you can share more information about the calculation logic, we can provide you with a solution...


    Expected Results

    Unit    Product    Item      Cost/Product??
    A HW ingB 0,42
    A SW ingA 0,31
    B SW ingD 0,22
    C HW ingB 0,34
    C HW ingC 0,37

    Best Regards