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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
morgtd30
Helper I
Helper I

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:

 
 
 

 

1 ACCEPTED SOLUTION

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()
)

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@morgtd30 , use is filtered

if(ISFILTERED('Jun'[slicer]),[junproj],blank())

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

morgtd30_0-1594127637491.png

 

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()
)
AllisonKennedy
Super User
Super User

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?

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

morgtd30_0-1594126475967.png

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.