Forum Discussion

DeepakSharma_01's avatar
DeepakSharma_01
Frequent Visitor
1 year ago
Solved

Calculate MTD Values from two disconnected Tables.

Hi Everyone, I have a budget table, which is having total budget of the month on last day of month. Like-   and another table is Date Table, and I want to allocate same value for all date o...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi DeepakSharma_01 ,

     

    In the solution I originally provided, there was no relationship between the date table and the budget table.

     

    To reproduce your problem I created a relationship between the two tables.

     

    The relationship between two tables can be ignored by using the REMOVEFILTERS function.

     

    The modified syntax is as follows:

    M_BUDGET_MTD_SALES_Test = 
    VAR CurrentDate = MAX(DIM_DATE[DATE])
    VAR Month_start = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1)
    VAR Month_end = EOMONTH(CurrentDate, 0)
    VAR TotalMonthBudget = 
    CALCULATE(
        SUM(BUDGET_FORECAST[BUDGET]),
        REMOVEFILTERS(DIM_DATE), 
        BUDGET_FORECAST[MONTH] = EOMONTH(CurrentDate, 0)
    )
    RETURN
    IF(
        CurrentDate >= Month_start && CurrentDate <= Month_end,
        TotalMonthBudget,
        BLANK()
    )

     

    The final page visualization is shown below:

     

    If it hasn't been resolved, please provide a Power BI Desktop file in progress (with sensitive information removed) that fully covers your issue or question in a usable format (not a screenshot). You can upload the PBIX file to a cloud storage service such as OneDrive, Google Drive (set up public access), SharePoint, or a Github repository, and then share the URL of the file.

     

    The pbix file is attached.

     

    If you have any other questions please feel free to contact me.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!