Forum Discussion

hstgeorge's avatar
hstgeorge
Helper III
6 years ago
Solved

Need Help with QTD - Custom Calendar

I have created the following calc:

 

QTD CY =
CALCULATE(SUM(NFSOP_SecVol_TD[UCs]),
FILTER(
ALL(NFSOP_SecVol_TD),
NFSOP_SecVol_TD[445 Quarter Number] = MAX(NFSOP_SecVol_TD[445 Quarter Number])
&& NFSOP_SecVol_TD[Week #] <= MAX(NFSOP_SecVol_TD[Week #])
)
)
 
This gets me the QTD value but it populates the same value on every line for evey geographical zone - I think I need to do the above calc as a column for it to calculated correctly across the file - how can I do this?
 
 
  • hstgeorge 

    Try applying  the ALL only to week and quarter instead of the whole table.

    QTD CY =
    CALCULATE (
        SUM ( NFSOP_SecVol_TD[UCs] ),
        FILTER (
            ALL ( NFSOP_SecVol_TD[445 Quarter Number], NFSOP_SecVol_TD[Week #] ),
            NFSOP_SecVol_TD[445 Quarter Number] = MAX ( NFSOP_SecVol_TD[445 Quarter Number] )
            && NFSOP_SecVol_TD[Week #] <= MAX ( NFSOP_SecVol_TD[Week #] )
        )
    )
  • hstgeorge , On a similar problem this what I have done

     

    Added new column to date table

    Start of Year = STARTOFYEAR(Dates[Date],"1/31") // Change year end date
    Add Qtr = QUOTIENT(DATEDIFF(Dates[Start of Year], Dates[Date],MONTH),3)*3
    Strat of Qtr = date(year(Dates[Start of Year]), month(Dates[Start of Year])+Dates[Add Qtr],1)
    Qtr No = "Q"& QUOTIENT(DATEDIFF(Dates[Start of Year], Dates[Date],MONTH),3)+1
    Week # = as per your calc

     

    Created measures like

    LQ New = CALCULATE(SUM(NFSOP_SecVol_TD[UCs], FILTER(ALL(Dates), Dates[Qtr Rank] =max(Dates[Qtr Rank])-1
    		&& Dates[Week #] = Max(Dates[Week #])))
    		
    LQ Running Total New =
     CALCULATE(SUM(NFSOP_SecVol_TD[UCs], FILTER(ALL(Dates), Dates[Qtr Rank] =max(Dates[Qtr Rank])-1 
    	&& Dates[Week #] <= Max(Dates[Week #])))
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi hstgeorge ,

     

    Check the formual and see if it's what you want.

    If not, please share some sample data and expected result to us.

    QTD CY = 
    CALCULATE(SUM('Table'[value]),
    FILTER(
    ALLEXCEPT('Table','Table'[geographical zone]),
    'Table'[quarter] = MAX('Table'[quarter])
    && 'Table'[week] <= MAX('Table'[week])
    )
    )

     

    Best Regards,

    Jay

4 Replies

  • hstgeorge 

    Try applying  the ALL only to week and quarter instead of the whole table.

    QTD CY =
    CALCULATE (
        SUM ( NFSOP_SecVol_TD[UCs] ),
        FILTER (
            ALL ( NFSOP_SecVol_TD[445 Quarter Number], NFSOP_SecVol_TD[Week #] ),
            NFSOP_SecVol_TD[445 Quarter Number] = MAX ( NFSOP_SecVol_TD[445 Quarter Number] )
            && NFSOP_SecVol_TD[Week #] <= MAX ( NFSOP_SecVol_TD[Week #] )
        )
    )
  • hstgeorge , On a similar problem this what I have done

     

    Added new column to date table

    Start of Year = STARTOFYEAR(Dates[Date],"1/31") // Change year end date
    Add Qtr = QUOTIENT(DATEDIFF(Dates[Start of Year], Dates[Date],MONTH),3)*3
    Strat of Qtr = date(year(Dates[Start of Year]), month(Dates[Start of Year])+Dates[Add Qtr],1)
    Qtr No = "Q"& QUOTIENT(DATEDIFF(Dates[Start of Year], Dates[Date],MONTH),3)+1
    Week # = as per your calc

     

    Created measures like

    LQ New = CALCULATE(SUM(NFSOP_SecVol_TD[UCs], FILTER(ALL(Dates), Dates[Qtr Rank] =max(Dates[Qtr Rank])-1
    		&& Dates[Week #] = Max(Dates[Week #])))
    		
    LQ Running Total New =
     CALCULATE(SUM(NFSOP_SecVol_TD[UCs], FILTER(ALL(Dates), Dates[Qtr Rank] =max(Dates[Qtr Rank])-1 
    	&& Dates[Week #] <= Max(Dates[Week #])))
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi hstgeorge ,

     

    Check the formual and see if it's what you want.

    If not, please share some sample data and expected result to us.

    QTD CY = 
    CALCULATE(SUM('Table'[value]),
    FILTER(
    ALLEXCEPT('Table','Table'[geographical zone]),
    'Table'[quarter] = MAX('Table'[quarter])
    && 'Table'[week] <= MAX('Table'[week])
    )
    )

     

    Best Regards,

    Jay