Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Target doesn't update based on period I select

I have 3 tables: 1) equipment 2) targets 3) company 4) calendar      Each equipment belongs to specific company and has a relative size. Each size has a fixed monthly target. Each ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    I create a sample to have a test.

    Data model:

    Period table is an unrelated dax table for slicer.

    Period = 
    DATATABLE (
        "Period", STRING,
        "Last Month", INTEGER,
        {
            { "Last 1 month", 1 },
            { "Last 2 months", 2 },
            { "Last 3 months", 3 }
        }
    )

    Measure:

    Achieve Target or not = 
    VAR _Last_Month = SELECTEDVALUE(Period[Last Month])
    VAR _Sales_IN_Last_Months = CALCULATE(SUM(Company[Sales ($)]),FILTER(Company,Company[Month] >= EOMONTH(MAX(Company[Month]),-_Last_Month)+1))
    VAR _ADD = ADDCOLUMNS(Equipment,"Target",RELATED(Targets[Monthly target]))
    VAR _SUMMARIZE = SUMMARIZE(_ADD,[Company],"Target",SUMX(FILTER( _ADD,[Company] = EARLIER([Company])),[Target]))
    VAR _Target_IN_Last_Months = SUMX(_ADD,[Target]) * _Last_Month
    RETURN
    IF(_Sales_IN_Last_Months >= _Target_IN_Last_Months,"Yes","No")

    Result is as below.

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.