Forum Discussion

morgtd30's avatar
morgtd30
Icon for Helper I rankHelper I
6 years ago
Solved

Help with filtering out measure

I have a slicer option that is "6/1/2020". When de-selected I need it to turn both measures blank.

JunProj = CALCULATE(SUM(Projections[Amount]), Projections[Month] = "6/1/2020")

I have another measure that also needs to be controlled by this filter. It combines JunProj and any actual sales before that date. It's a mess but I've been having trouble figuring this out:

Jun 20 = TOTALYTD([JunProj], 'Date'[Date])

+

    IF(AND(

    calculate(sum(

    Opportunity[Amount]),Opportunity[StageName]="Closed Won",Opportunity[CloseDate]<date(2020,6,1))

    = TOTALYTD([JunProj], 'Date'[Date]),

    CALCULATE([JunProj]>date(2020,6,1))=BLANK()),

    BLANK(),

 

    TOTALYTD(CALCULATE(SUM(Opportunity[Amount]),Opportunity[StageName]     = "Closed Won",Opportunity[CloseDate] < DATE(2020,6,1)) , 'Date'[Date])

    )

It still displays data prior to 2020,6,1:

 
 
 

 

  • I was able to solve the problem with the following formula:

    Apr Projection =
    TOTALYTD([AprProj], 'Date'[Date])
    +
    IF(
    COUNTROWS(
    FILTER(
    MonthTable,
    MonthTable[ProjectionMonth] = "4/1/2020")
    ) >0,

    TOTALYTD(CALCULATE(SUM(Opportunity[Amount]),Opportunity[StageName] = "Closed Won",Opportunity[CloseDate] < DATE(2020,4,1)) , 'Date'[Date]),BLANK()
    )

5 Replies

  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion
    Calculate context transition is tricky, so you'll get the Jun value no matter what is selected in slicer.

    Try: JunProj = SUMX(FILTER(Projections, Projections[Month] = "6/1/2020"), Projections[Amount])

    What is it you're actually wanting to achieve though? I question why a slicer selection should render a measure to be blank, and why you're creating measures with such specific dates hard coded into them? Can you provide dummy data of your sample model and explain what you need?
    • morgtd30's avatar
      morgtd30
      Icon for Helper I rankHelper I

      Here's what the line graph looks like. I'm building a way to compare YTD projections for any given current or historical month. The 6/1/2020 is one of many filters to remove the lines off the graph as necessary. The green line is the current YTD. It works great other than those amounts that still show up even after the month is filtered out. It causes the tool-tip to fill with bad data.

    • morgtd30's avatar
      morgtd30
      Icon for Helper I rankHelper I

      Also to be clear it's June 20 that is still displaying data:

       

      • morgtd30's avatar
        morgtd30
        Icon for Helper I rankHelper I

        I was able to solve the problem with the following formula:

        Apr Projection =
        TOTALYTD([AprProj], 'Date'[Date])
        +
        IF(
        COUNTROWS(
        FILTER(
        MonthTable,
        MonthTable[ProjectionMonth] = "4/1/2020")
        ) >0,

        TOTALYTD(CALCULATE(SUM(Opportunity[Amount]),Opportunity[StageName] = "Closed Won",Opportunity[CloseDate] < DATE(2020,4,1)) , 'Date'[Date]),BLANK()
        )