Forum Discussion

JohanData's avatar
JohanData
Icon for Resolver I rankResolver I
6 years ago
Solved

How to exclude / filter last month YTD-calculation

Hi there,   Could you please help me out with the following?   Imagine: you have a dataset with only YTD-data. Ths facttable has only 2 columns: date & Quantity YTD. In order to caculate the amou...
  • JohanData's avatar
    JohanData
    6 years ago

    Hi there,

     

    No, this does not meet the requirements if you roll it up to year. 

     

    Anyhow, this is how fixed the issue myself:

     

    # Quantity Prep =
    var quantity =
    CALCULATE ( [# Quantity YTD] - [# Quantity YTD PM] , DIM_Calendar[Monthnumber] <> 1 )
    var selected_month = SELECTEDVALUE ( DIM_Calendar[Monthnumber])
    return
    SWITCH ( true,
    selected_month = 1 , [# Quantity YTD] ,
    ISBLANK([# Quantity YTD]) , BLANK() ,
    quantity
    )
     
    # Quantity =
    sumx ( VALUES ( DIM_Calendar[Year/Month] ) , [# Quantity Prep])