Forum Discussion

tahir9's avatar
tahir9
Frequent Visitor
8 years ago
Solved

Populating future dates with previous year and same month results?

Hello my data is something like the below and i want to create a New Pols column, i tried the following formula but it doesn't populate future dates only populates the dates less than today... 

 

Parallel = IF(Query1[ActivityDate]<NOW(), Query1[POLCNT], CALCULATE(SUM(Query1[POLCNT]),FILTER(Query1,Query1[Month]=MONTH(Query1[ActivityDate])),FILTER(Query1,Query1[Year]=YEAR(Query1[ActivityDate])-1))*1.2)

 

StateRepChannelactivityDateyearmonthdayPolcntParallel
xAM1/1/201020101111
xBK1/1/201120111122
xAL1/1/201220121133
yCK1/1/201320131144
yDL12/1/2017201712155
yEN12/1/201820181216          7.20

 

  • Hi tahir9

     

    I've added in the additional checks for those columns (highligted the changes in red-bold)

     

    Parallel = 
    VAR MyDate = DATE('Table'[year],'Table'[month],1)
    VAR SumOfMonthLastYear = 
        SUMX(
            FILTER(
                'Table1',
                'Table'[year] = EARLIER('Table'[year]) - 1 &&
                'Table'[month] = EARLIER('Table'[month]) &&
                'Table'[State] = EARLIER('Table'[State]) &&
                'Table'[Rep] = EARLIER('Table'[Rep]) &&
                'Table'[Channel] = EARLIER('Table'[Channel])
                ),
           'Table'[Polcnt]
           )
        
    RETURN 
        IF(
            MyDate< TODAY() ,
            --- THEN --- 
            'Table'[Polcnt] , 
            --- ELSE ---
            SumOfMonthLastYear * 1.2
            )

9 Replies

  • Phil_Seamark's avatar
    Phil_Seamark
    Microsoft Employee

    HI tahir9

     

    What is the number you are after in the Parallel column for the bottom row?  Is 7.20 the number you want?  Or is this the output of the calculation that isn't working how you would like?

    • tahir9's avatar
      tahir9
      Frequent Visitor
      Yeah the 7.2 which is just the 6 multiplied by 1.2.
      • Phil_Seamark's avatar
        Phil_Seamark
        Microsoft Employee

        Is this calculated column close?

         

        Parallel = 
        VAR MyDate = DATE('Table1'[year],'Table1'[month],1)
        RETURN 
            IF(
                MyDate< TODAY() ,
                --- THEN --- 
                'Table1'[Polcnt] , 
                --- ELSE ---
                'Table1'[Polcnt] * 1.2
                )