cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
kevin_peña
Regular Visitor

How to get data range from slicer

Good day 

I need to calculate the days between the data range of a slicer. I've been using the ALLSELECTED function but i noticed that the value it gets me is from the table that is linked to the slicer, not the slicer itself. So when i use another slicer that's linked to the same table, it gets me two values 

kevin_pea_0-1671478005984.png

For example, in this picture, the date slicer goes from 10/1/2022 to 12/15/2022 and the last date in the table is 12/15/2022 (as you can see in the card). But if i change the slicer in left (The Status), it automatically changes the date according to the last date in the table (as you can see in the card, image below), but is not the same date of the max range of the slicer. 

kevin_pea_1-1671478191348.png

As i said before, what i need is the min and max range of the date slicer (in this case 10/1/2022 - 12/15/2022) regardless of the data on the table

 

Kind regards  

 

6 REPLIES 6
samdthompson
Memorable Member
Memorable Member

Hello, make sure your slicer you have there is filtering the card and that the measure is using the same table as used in the slicer

 

 

// if this is a solution please mark as such. Kudos always appreciated.

Thanks for answering in short notice. I've checked in the interactions and the card is being filtered by the date slicer but still is not showing the values it should. The only thing i changed of your formula is that i'm using the .[Date] cause it was showing an error

kevin_pea_0-1671483827141.png

 

samdthompson
Memorable Member
Memorable Member

Hello, make this measure. It will just pickup the min and max date from the slicer:

 

DayDiff =
var _min=FIRSTDATE(Query1[Raised_date])
var _max=LASTDATE(Query1[Raised_date])
return
DATEDIFF(_min,_max,DAY)
 
Cheers
// if this is a solution please mark as such. Kudos always appreciated.

This one looks good but it gives me the whole number of days since the table was created, the table starts on 1/31/2016 and ends today 12/19/2022 so the result is 2556 days, that means is ignoring the slicer filter

kevin_pea_0-1671482331242.png

 

samdthompson
Memorable Member
Memorable Member

You could do this a bunch of ways. prob the easiest is to make a text box and use the values functionality to do some like:

 

This report covers the period min_date to max_date 

 

If you havent done this before heres the MS page on how to do it:

Add text boxes, shapes, and smart narrative visuals to Power BI reports - Power BI | Microsoft Learn

 

Hope this helps,

Cheers,

 

 

// if this is a solution please mark as such. Kudos always appreciated.

The thing is that i need the values for a measure, and it has to be the same values in the date slicer regardless of the filter in the status slicer. If i select the dates from 10/1/2022 to 12/15/2022, it should count 14 days whether the status slicer is in "ABORTED" or not

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors