Forum Discussion

bangsheadondesk's avatar
bangsheadondesk
Frequent Visitor
3 years ago

Dynamic MTD target by chart and card

Hi,
I am trying to craft visuals that will

a) show what the mtd target should be based on what day of the month is selected from slicer or filtered value from another chart (need for both card and column in a larger chart)

b) display as a reference line for where we should be at in the month in order to hit targets (line chart)

c) be accurate for current and historical months, depending on what is selected in date slicer

 

I have a date table with fields (among many others)

'date'[date] (date/time format)

        CALENDARAUTO ( 6 ),
        AND (
            [date] >= DATE ( 2020, 7, 1 ),
            [date] <= MAX ( 'Opportunity'[Close Date] )


'date'[CD] (for calendar day, whole number format)

"CD", DAY([Date]),


and 'Target' Table built in Power Query with fields

[Date],

[Days in Month],

[Leads Target],

and [Leads Target by Day] (formula: each [Leads Target] / [Days in Month])

 

They're joined on 'Date'[Date] to 'Target'[Date]

     


Other tables include a date2 (joined on [date], and target[date]) that I tried using to give me a 2nd table for a lookupvalue option (didn't work, obviously)

I've tried this, which works in a card and gives either max goal for month or goalmtd as of today, as long as only a single month date range is selected:

DG Works =
var dailygoal = calculate(sum('Target'[Leads Target by Day]), USERELATIONSHIP('Date'[Date],'Target'[Date]))
var maxdate = CALCULATE(max('Date'[CD]), ALLSELECTED('Date'[Date]))
var dayofperiod = CALCULATE(LOOKUPVALUE('Date'[CD],'Date'[Date], TODAY()))
var testdailygoal = if(SELECTEDVALUE('Date'[Mo Diff]) = 0, dayofperiod, maxdate)
return
CALCULATE(dailygoal * testdailygoal, ALLSELECTED('Date'[Date]))  works card, gives either max goal for month or goalmtd as of today

But it doesn't work historically, and it doesn't work in a line chart with CD on the x-axis. (I need the x-axis to be CD, because this has to tie into other overlapping charts.)  Plus, since one requirement is either the ability to select a day from the chart and get the dynamic mtd goal for that point in the month or a static report that shows mtd goal target for end of month and the mtd target frozen at halfway through month, this isn't sufficient.

 

  

 

I have also tried a whole host of other things that won't work.  I won't bother posting them, but some--certainly not all--are in the sample file.  (Others were deleted in frustration--just trust me, there were lots of attempts.)  I'm sure I'm probably missing something silly, but my brain is fried and not working well at this point.  It may require two separate measures, one for chart and another for card.

Looks like my security filters won't allow me to upload the sample file I recreated.  I'll see if there's a workaround, but posting in meantime.

Please help?