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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
OrM
Frequent Visitor

Filter not affecting Visual, but measure in the visual affected by the filter

Hi everyone,

 

I have encountered one issue in power bi desktop. 

I have a line chart on the page with 2 measures: [Variable 2020] and [Variable 2021]. I have turned off the interaction between the filter and the line chart, otherwise I have only one month in the line chart (the month filter is necessary for other visuals on the page).

 

I want to set up [Variable 2021] so that it will show the data only till selected month, i.e. if February is selected on the month slicer [Variable 2] will show only January & February data and the rest will be blank.  

OrM_1-1615557780386.png

https://community.powerbi.com/t5/Desktop/Line-Chart-until-selected-month/td-p/534468 solution on the provided link is not working for me. Would be pleased if you can help me figure out how to do it. Thank you!

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You could use a slicer where you can select a date range up until a particular date rather than selecting a single date. If that's not an option, then (I don't know if this is the best practice but) I've solved similar date problems as follows:

 

Make sure you have two calendar tables. The first is the standard date dimension table with a relationship to your fact table. The second is an independent parameter table with no relationships. The standard calendar table is used on your x-axis. The parameter calendar table is used for your slicer. Write measures that read your date slicer and apply that selected date using the logic you want.

 

For example:

 

Filtered Variable 2020 =
VAR DateSelected = SELECTEDVALUE ( DateParam[Date] )
RETURN
    CALCULATE ( [Variable 2020], DateDim[Date] <= DateSelected )

 

 

This way the DateParam table doesn't filter your x-axis since there's no relationship but it's still used to apply a date filter in the measure.

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

You could use a slicer where you can select a date range up until a particular date rather than selecting a single date. If that's not an option, then (I don't know if this is the best practice but) I've solved similar date problems as follows:

 

Make sure you have two calendar tables. The first is the standard date dimension table with a relationship to your fact table. The second is an independent parameter table with no relationships. The standard calendar table is used on your x-axis. The parameter calendar table is used for your slicer. Write measures that read your date slicer and apply that selected date using the logic you want.

 

For example:

 

Filtered Variable 2020 =
VAR DateSelected = SELECTEDVALUE ( DateParam[Date] )
RETURN
    CALCULATE ( [Variable 2020], DateDim[Date] <= DateSelected )

 

 

This way the DateParam table doesn't filter your x-axis since there's no relationship but it's still used to apply a date filter in the measure.

Thank you for your reply, Alexis! On the link provided in the original post the same solution is proposed. But I want to avoid creating an extra month slicer.

I suppose it is not possible without creating an extra slicer.

Yeah, if you want selecting a single month in a drop-down to do something other than selecting a single month on your axis, then you have to make things more complicated.

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

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