Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Power BI Desktop (DirectQuery) Sum Measure Based on Dynamic Dates

Hi DAX Experts,   Hope you could help me again or hear your suggestions (I am still learning PowerBI).   Using DirectQuery, how to get the sum of a measure based on two dynamic dates like getting...
  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi Anonymous,

     

    >>But I need to only get 3,588 (the budget from 3 January to 19 January).

    In my opinion, you can use 'lookupvalue' function to find out current date, then use it as condition to filter on calculate formula.

    MTDBudget = 
     IF(MAX(YTDBudget[CurMonFlag])= 1,CALCULATE( SUM(YTDBudget[SalesBudget] ),FILTER(ALLSELECTED(YTDBudget),'YTDBudget'[CurMonFlag] = 1 && [BudgetDate] <=LOOKUPVALUE(YTDBudget[BudgetDate],YTDBudget[CurDayFlag],1)  )))

     

    Regards,

    Xiaoxin Sheng