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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
DrewSmith
Helper III
Helper III

Variable target calculation for KPI Card

Hi, 

I'm trying to build out a new report that has a date slicer linked to a calendar table. 
I've got KPI cards showing MTD and previous MTD. 

I want to amend this so I can see, for example: 

- If I change the dates to 8th to 14th Jan the KPI card shoes those sales figures, along with 1st to 7th in the target section 
- If I select the whole of December, i'd want to see November in the target section. 
- If I select the whole of Q4 then I'd see Q3 in target section. 

How would I write a variable target calculation? 

1 REPLY 1
Anonymous
Not applicable

Hi @DrewSmith 

 

Based on the question you asked, here's how to judge the slicer range:

 

“Calendar”

vnuocmsft_0-1705394080074.png

 

 

You can calculate sales by judging the slicer range dynamics

Date Range Type = 
    VAR MinDate = MIN('Calendar'[Date])
    VAR MaxDate = MAX('Calendar'[Date])
    VAR enddate = EOMONTH(MaxDate, 0)
    VAR startdate = EOMONTH(MinDate, -1) + 1
    VAR MonthDiff = DATEDIFF(MinDate, MaxDate, MONTH)
RETURN
IF(MonthDiff = 0 && MinDate <> startdate, "Alternate Days",
    IF(MonthDiff = 0 && MaxDate = enddate && MinDate = startdate, "Whole Month",
        IF(MonthDiff = 2 && MaxDate = enddate && MinDate = startdate, "Full quarter",
            BLANK()
        )
    )
)

 

Here is the result.

vnuocmsft_1-1705394107492.png

 

vnuocmsft_2-1705394151559.png

 

vnuocmsft_3-1705394185970.png

 

 

 

Regards,

Nono Chen

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

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors