cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper I

## Check if slicer is selected while same dimension is used in chart

Hello,

My problem is pretty simple. I have a date Slicer (Year, Month & Day) and a Chart showing sales with Date as an axis.

I would like to show only rolling 12 months data on my sales measure when the slicer contains no selection.

The expected result is the following

And when no date is selected, show sales only for 02-2022 to 02-2023

Is it possible to performs this without having to add an independent date slicer ?

1 ACCEPTED SOLUTION
Super User

For an entirely measure approach try something like this:

(Filter measure)

Measure 44 =
IF(ISFILTERED('Calendar'[Year]),
1,

IF(
MAX('Calendar'[Date]) in DATESBETWEEN('Calendar'[Date], TODAY()-365, TODAY()),1,0)

)

Base measure:
Measure 45 = SUM('Table (28)'[Value])

Place filter measure into filter pane like this:

With filter:

You might need to play around with the dimensions to get the visual you want, but filter measure would be the most logical approach if you don't want new slicers or tables

Proud to be a Super User!

3 REPLIES 3
Super User

Hi,

Here is one way to do this:

Data:

Dax:

Measure 43 =
IF(ISFILTERED('Calendar'[Year]),

CALCULATE(SUM('Table (28)'[value]),USERELATIONSHIP('Visual Calendar'[Date],'Table (28)'[example:])),

CALCULATE (
SUM('Table (28)'[value]),
DATESBETWEEN ('Calendar'[Date],TODAY()-365, TODAY()),USERELATIONSHIP('Visual Calendar'[Date],'Table (28)'[example:])
)

)

Here I am cheking if the Year is filtered and if this is the case we are using a simple SUM dax. Otherwise, we will calculate 12m rolling values based on today. The visual uses a duplicate of calendar table "visual calendar" and the USERELATIONSHIP in dax activates the calculation so that it will gets assigned to correct months.

End result (without filters 12m values):

(with filters, values accroding to slicer):

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

Proud to be a Super User!

Helper I

The solution is great but kinda similar of having another table as a Slicer. My aim was to be able to check if the slicer is selected in DAX even though it might bi filtered via the X-Axis in the visual.

Super User

For an entirely measure approach try something like this:

(Filter measure)

Measure 44 =
IF(ISFILTERED('Calendar'[Year]),
1,

IF(
MAX('Calendar'[Date]) in DATESBETWEEN('Calendar'[Date], TODAY()-365, TODAY()),1,0)

)

Base measure:
Measure 45 = SUM('Table (28)'[Value])

Place filter measure into filter pane like this:

With filter:

You might need to play around with the dimensions to get the visual you want, but filter measure would be the most logical approach if you don't want new slicers or tables

Proud to be a Super User!

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - August 2024

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

#### Fabric Community Update - August 2024

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

Top Solution Authors
Top Kudoed Authors