Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Berrcikk
Frequent Visitor

KPI Visual - target value

Hi,

I’m having a problem with creating a simple report with one chart and one target visual. Let’s assume that in my model, I have fact table with total sales,product column and dim calendar. What I would like to achieve, is to calculate target on KPI visual card, as a a value of total sales for previous period on visual. So if on chart there are years, KPI card should display value for newest year, and target as total for previous year. Same, if I’m presenting quarters, then It should calculate value for current quarter, and target value as value for previous quarter. Also, it would be great to have an exception, that if there is no value for previous period, then target is not calculated. As for now, I’ve hard coded it for months, but I believe there is easier solution that I’m not aware of.

3 ACCEPTED SOLUTIONS

Hi @Berrcikk 
You can use isinscope function to manipulate with the date hierarchies and calculate your goal according to the selections.
Please refer to the attached video :
https://www.youtube.com/watch?v=_p9E8fiDRDw

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Hi @Berrcikk 
INSCOPE / Isfiltered will work, as the "goal" of the card filtered by bars on the graph.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

Hi @Berrcikk 
You need to apply the needed logic for goals based on the hierarchy filter, if i understood you correctly, on year it should be a year ago, quarter, quarter ago, etc . 
So it something like :
test isincscope =
VAR date1 =
    MAX ( DimCalendar[Date] )
VAR vMonth =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
         datedadd( vFactSales[Date] ,-1,month)
    )
VAR vQuarter =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
        datedadd( vFactSales[Date] ,-1,quarter)
    )
VAR vYear =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
        datedadd ( vFactSales[Date] ,-1,Year)
    )
VAR scope1 =
    SWITCH (
        TRUE (),
        ISINSCOPE ( DimCalendar[Date].[Month] )vMonth,
        ISINSCOPE ( DimCalendar[Date].[Month] )vQuarter,
        ISINSCOPE ( DimCalendar[Date].[Month] )vYear,
        1
    )
RETURN
    scope1

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

7 REPLIES 7
Berrcikk
Frequent Visitor

@Ritaf1983 Sure, I hope this format will be fine.

So fact table looks more or less like that.

sales valuedatecar type
1004.10.2020A
2519.09.2020A
3217.08.2020B
1414.06.2020B

 

Now, let's assume we have a slicer date, and a clustered chart with sales on Y axis, and date on X axis.

Based on what granularity on chart is shown (ex. years, months, quarters), KPI card should display value for current month, and target for previous one. So for screen below, it should be 548 and 535.

Berrcikk_0-1697279232915.png

However, if I change granularity to quarters, as on the screen below, it should present 1.3k, and 1k.

Berrcikk_1-1697279315759.png

 

Hi @Berrcikk 
You can use isinscope function to manipulate with the date hierarchies and calculate your goal according to the selections.
Please refer to the attached video :
https://www.youtube.com/watch?v=_p9E8fiDRDw

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Hi @Ritaf1983 
I believe INSCOPE function is not what I'm looking for, as date hierarchy is determined in separate visual, so therefore I think it doesn't work in this scenario 

Hi @Berrcikk 
INSCOPE / Isfiltered will work, as the "goal" of the card filtered by bars on the graph.

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

I'm not sure If I understand you correctly, what you say definetely makes sense, but I have a feeling I don't catch it... For me it looks like, that changing data granularity on chart, doesn't effect in any way my other visuals. I'm very grateful, but could you maybe share with me working example of such a feature? Below is my code for calculating current goal, that I would like to react to changes in granularity in other chart


test isincscope =
VAR date1 =
    MAX ( DimCalendar[Date] )
VAR vMonth =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
        MONTH ( date1 ) = MONTH ( vFactSales[Date] )
    )
VAR vQuarter =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
        QUARTER ( date1 ) = QUARTER ( vFactSales[Date] )
    )
VAR vYear =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
        YEAR ( date1 ) = YEAR ( vFactSales[Date] )
    )
VAR scope1 =
    SWITCH (
        TRUE (),
        ISINSCOPE ( DimCalendar[Date].[Month] )vMonth,
        ISINSCOPE ( DimCalendar[Date].[Month] )vQuarter,
        ISINSCOPE ( DimCalendar[Date].[Month] )vYear,
        1
    )
RETURN
    scope1

And a screen of how other visual doesn't react...

Berrcikk_0-1697297702104.png

 


Thanks for your patience! 

Hi @Berrcikk 
You need to apply the needed logic for goals based on the hierarchy filter, if i understood you correctly, on year it should be a year ago, quarter, quarter ago, etc . 
So it something like :
test isincscope =
VAR date1 =
    MAX ( DimCalendar[Date] )
VAR vMonth =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
         datedadd( vFactSales[Date] ,-1,month)
    )
VAR vQuarter =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
        datedadd( vFactSales[Date] ,-1,quarter)
    )
VAR vYear =
    CALCULATE (
        SUM ( vFactSales[Total Sales] ),
        datedadd ( vFactSales[Date] ,-1,Year)
    )
VAR scope1 =
    SWITCH (
        TRUE (),
        ISINSCOPE ( DimCalendar[Date].[Month] )vMonth,
        ISINSCOPE ( DimCalendar[Date].[Month] )vQuarter,
        ISINSCOPE ( DimCalendar[Date].[Month] )vYear,
        1
    )
RETURN
    scope1

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile
Ritaf1983
Super User
Super User

Hi @Berrcikk 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.