Forum Discussion

RoHa's avatar
RoHa
Frequent Visitor
2 years ago
Solved

KPI visual does not accumulate

Hi all,

I have an ongoing issue with my KPI visual:

I have two tables, one called "ANT - Income Statement" and the other is called "ANT - Budget". The date bridge table between these two is called "ANT - Date". "ANT - Budget" has the columns "Sales Budget" and "MonthName". I have already linked the columns "Month Name" and "MonthName" to "Month" in "ANT - Date" via a many-to-many relationship. The slicer has the column "Month" of table "ANT - Date" as field.


What I want is the following:

I have a KPI visual and want to include a measure for sales budget as the target number. This measure should accumulate the sales budget as per the selected months in the slicer. For example, if I select January and February, the KPI should show the accumulated budget for these two months as the target number. If I select January, February and May, the KPI visual should show the accumulated budget for these three months as the target number and so on..


What happens:
When I include the below code, it only shows the budget for the most recent month when I select multiple months. Hence, it does not accumulate.

Accumulated Sales Budget =
VAR SelectedMonths = VALUES('ANT - Date'[Month])
RETURN
    CALCULATE(
        SUM('ANT - Budget'[Sales Budget]),
        TREATAS(SelectedMonths, 'ANT - Date'[Month])
    )



Can you please help!?

Greetz,

Robin.



  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi RoHa ,

     

    Please try:

     

    Here's the example data I created:

    Date

    Sales Budget

    MonthName

    2024-01-01

    100

    January

    2024-02-01

    100

    February

    2024-03-01

    100

    March

    2024-04-01

    100

    April

    2024-05-01

    100

    May

    2024-06-01

    100

    June

    2024-07-01

    100

    July

     

    Create a Measure:

    Accumulated Sales Budget = 
    VAR SelectedMonths = VALUES('ANT - Date'[Month])
    RETURN
        IF(
            ISFILTERED('ANT - Date'[Month]),
            CALCULATE(
            SUM('ANT - Budget'[Sales Budget]),
            'ANT - Budget'[MonthName] in SelectedMonths
        ),
        0)

     

    The final page visualization is shown below:

     

    I would be grateful if you could provide me with the pbix file or sample data.

     

    Remember to remove sensitive data and do not log in to your account in Power BI Desktop when uploading the pbix file.

     

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

     

    The pbix file is attached.

     

    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!

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi RoHa ,

     

    Please try:

     

    Here's the example data I created:

    Date

    Sales Budget

    MonthName

    2024-01-01

    100

    January

    2024-02-01

    100

    February

    2024-03-01

    100

    March

    2024-04-01

    100

    April

    2024-05-01

    100

    May

    2024-06-01

    100

    June

    2024-07-01

    100

    July

     

    Create a Measure:

    Accumulated Sales Budget = 
    VAR SelectedMonths = VALUES('ANT - Date'[Month])
    RETURN
        IF(
            ISFILTERED('ANT - Date'[Month]),
            CALCULATE(
            SUM('ANT - Budget'[Sales Budget]),
            'ANT - Budget'[MonthName] in SelectedMonths
        ),
        0)

     

    The final page visualization is shown below:

     

    I would be grateful if you could provide me with the pbix file or sample data.

     

    Remember to remove sensitive data and do not log in to your account in Power BI Desktop when uploading the pbix file.

     

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

     

    The pbix file is attached.

     

    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!