Forum Discussion

srk_powerbi's avatar
srk_powerbi
Helper II
5 years ago
Solved

calculate measure help..

hi , i have a table like below. I want to calculate a measure base on current month. Lets say we are in june month now, so I want to calcuate  a measure called '% expected' by using this logic % ce...
  • Ashish_Mathur's avatar
    5 years ago

    Hi,

    You may download my PBI file from here.

    Hope this helps.

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi srk_powerbi ,

     

    Based on your sample data, you can create the following measure. My measure is updated dynamically, no slicer selection is required.

     

     

    % cexpected = 
    var _aa=CALCULATE(SUM('Table'[Amount]),FILTER('Table',[CalcType]="sales"&&[Fy]<=YEAR(TODAY())&&[Fm]<=MONTH(TODAY())))
    var _bb=CALCULATE(SUM('Table'[Amount]),FILTER('Table',[CalcType]="sales expected"&&[Fy]<=YEAR(TODAY())&&[Fm]<=MONTH(TODAY())))
    return DIVIDE(_aa-_bb,_aa)
    

     

     

    Tips: [Fm] column is a calculated column which retruns the month number.

    Best Regards,

    Stephen Tao

     

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