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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
zenonsbelskiss
Frequent Visitor

Filter for a measure similar to a filter for visualization

Hello, PowerBI Gurus,

 

So I have a simple measure that computes a forecast for the selected period. When I use a card visualization and apply a filter to it it works just fine. However, if I need to use the measure in other calculations, then the filter which I applied to the card gets lost.

 

My question is: How do I incorporate the filter directly into the measure? (I need a filter that filters out just the chosen year)

 

Here is my measure:

Forecast 2019 = CALCULATE(SUM(MANAGERS[Plan 2019])/12, ALL())*DISTINCTCOUNT(SALES[Year-Month])

 

Thank you in advance,

PowerBI beginner.

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @zenonsbelskiss ,

 

You may change the measure like DAX below, which uses ALLSELECTED function to catch the filter.

 

 

Forecast 2019 =
CALCULATE ( SUM ( MANAGERS[Plan 2019] ) / 12, ALLSELECTED ( MANAGERS ) )
    * CALCULATE ( DISTINCTCOUNT ( SALES[Year-Month] ), ALLSELECTED ( SALES ) )

 

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

Fowmy
Super User
Super User

@zenonsbelskiss 

I don't have enough information about your model, try this measure if it can be used. I supposed you have Dates table

Forecast 2019 = 
VAR __YEAR = SELECTEDVALUE(DATES[Year]) RETURN
CALCULATE(
    SUM(MANAGERS[Plan 2019])/12, 
    DATES[Year] <> __YEAR
)
*
DISTINCTCOUNT(SALES[Year-Month])

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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