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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
WSeirafi
Helper I
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

 

WSeirafi_0-1676299002773.png

 

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

 

WSeirafi_1-1676299062607.png

 

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

Thanks for your help

 

1 ACCEPTED SOLUTION

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:

ValtteriN_0-1676302314979.png

 

With filter:

ValtteriN_1-1676302330862.png

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ValtteriN
Super User
Super User

Hi,

Here is one way to do this:

Data:

ValtteriN_0-1676299481838.png

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):
ValtteriN_0-1676301157002.png

 

(with filters, values accroding to slicer):

ValtteriN_1-1676301185970.png

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!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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.

Thanks for your help !

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:

ValtteriN_0-1676302314979.png

 

With filter:

ValtteriN_1-1676302330862.png

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





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors