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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
HMSF
Frequent Visitor

DAX TO GET THE NEXT 3 SHIPMENTS

Hi everyone,

 

I am new Power BI user. I have a table with the vessel name and the volume to be discharged and I want to create a visual that shows me the next three shipments to be discharged depending on the slicer range. I would like to know why kind of DAX formula I can use. I have been trying to use the Top N filter but it doesn't woprk so I am not sure what I am doing wrong. 

HMSF_0-1715811722107.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @HMSF ,

You can follow the steps below to get it:

1. Create a date dimension table(Do not create any relationship with your fact table)

2. Create a slicer and apply the date field of the above date dimension table on it

3. Create a measure as below

Flag = 
var _mindate=min('Date'[Date])
var _maxdate=max('Date'[Date])
var _seldate=selectedvalue{'Facttable'[Date])
return if(_seldate>=_mindate&&_seldate<=_maxdate,1,0)

4. Create a table visual and apply the visual-level filter with the condition (Flag is 1)

Best Regards

View solution in original post

5 REPLIES 5
HMSF
Frequent Visitor

I want that when I select a date range in the slicer I can see the current shipments and the next three shipments 

Anonymous
Not applicable

Hi @HMSF ,

You can follow the steps below to get it:

1. Create a date dimension table(Do not create any relationship with your fact table)

2. Create a slicer and apply the date field of the above date dimension table on it

3. Create a measure as below

Flag = 
var _mindate=min('Date'[Date])
var _maxdate=max('Date'[Date])
var _seldate=selectedvalue{'Facttable'[Date])
return if(_seldate>=_mindate&&_seldate<=_maxdate,1,0)

4. Create a table visual and apply the visual-level filter with the condition (Flag is 1)

Best Regards

Anonymous
Not applicable

Hi @HMSF ,

Which field you applied on the slicer? What's your expected result? Could you please explain the backend logic base on the provided sample data? It would be helpful to get the solution. Thank you.

vyiruanmsft_0-1715826355900.png

Best Regards

The field that I applied for the slicer is the date. The result that I want is that when I choose a date range (slicer)  I can see the next 3 vessels name with the material and the volume.

Anonymous
Not applicable

Hi @HMSF ,

Thanks for your reply. I'm still not clear about your requirement. As you said, you applied a date field on the slicer. Base on your sample data, if select the date from 5/1/2024 to 5/22/2024, then it will display 3 rows with red square in the below screenshot?

vyiruanmsft_0-1716361593342.png

Best Regards

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.