Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Column with values from different period

Hello everyone,

 

I'm looking for a column that equals the headcount column below except for 2018, where I want to "overwrite" the headcount with December 18 values. So if Dec18 = 1 than all other months in 18 should be 1 too. Anybody knows an easy way to do this?

 

I tried to use dateadd with instead of "-1" using "+(12 - Month)" but that returns only blanks.

 

Thanks

 

NameYearMonth numberMonthHeadcount

Person120181January1
Person120182February1
Person120183March1
Person120184April1
Person120185May1
Person120186June1
Person120187July1
Person120188August1
Person120189September1
Person1201810October1
Person1201811November1
Person1201812December1
Person120191January1
Person120192February1
Person120193March1
Person120194April1
Person120195May1
Person120196June0
Person120197July0
Person120198August0
Person120199September0
Person1201910October0
Person1201911November0
Person1201912December0
Person220181January1
Person220182February1
Person220183March1
Person220184April1
Person220185May1
Person220186June1
Person220187July1
Person220188August1
Person220189September1
Person2201810October1
Person2201811November0
Person2201812December0
Person220191January0
Person220192February0
Person220193March0
Person220194April0
Person220195May0
Person220196June0
Person220197July0
Person220198August0
Person220199September0
Person2201910October0
Person2201911November0
Person2201912December0

3 Replies

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    HI, Anonymous

    I'm a little confused about your description, do you mean that just for 2018, if headcount on December 18 =1 then all other months in 18 should be 1 too, otherwise the headcount should stay the same?

    If so, try this formual:

    Column = 
    VAR Dec18 =
        IF (
            Table1[Year] = 2018,
            CALCULATE (
                SUM ( Table1[Headcount] ),
                FILTER (
                    Table1,
                    Table1[Name] = EARLIER ( Table1[Name] )
                        && Table1[Year] = 2018
                        && Table1[Month] = 12
                )
            )
        )
    RETURN
        IF ( Dec18 = 1, 1, Table1[Headcount] )

    If not your case, please share the expected output of the sample data below.

     

    Best Regards,

    Lin

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-lili6-msft,

       

      Thank you very much! It is like you say, except that Jan18 to Nov18 should be set equal to Dec18 always (so not only if Dec 18=1). Would that change the logic?

      • v-lili6-msft's avatar
        v-lili6-msft
        Icon for Community Support rankCommunity Support

        hi, Anonymous 

        You could try it by yourself, the logic should be the same.

        If it is not your case, please share pbix file or some data sample and expected output. Do mask sensitive data before uploading.

         

         

        Best Regards,

        Lin