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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
PMeadows
Regular Visitor

Only have dynamic MIN and MAX date datapoints on line chart

Hello,

I have a problem where I am trying to only show the MIN and MAX date points on a line chart. The MAX date will dynamically change with a slicer from another column so I can't use a static RANX on a calculated column.

Here's a visual of my problem.

PMeadows_0-1711063681070.png

 

 

As you can see there are loads of 0 values. I am looking to get a straight line from the first point to a dynamic last point based on a slicer.

Does anyone have any thoughts on how to do this with measures?

Thanks a lot,
Pete


 

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @PMeadows ,

Please create a new measure like:

Measure = 
VAR __first_noblank_date = CALCULATE(FIRSTNONBLANK('Date'[Date],[YourMeasureName]),ALLEXCEPT('Table','Table'[Legend Field]))
VAR __last_noblank_date = CALCULATE(LASTNONBLANK('Date'[Date],[YourMeasureName]),ALLEXCEPT('Table','Table'[Legend Field]))
VAR __first_noblank_value = CALCULATE([YourMeasureName],'Date'[Date]=__first_noblank_date)
VAR __last_noblank_value = CALCULATE([YourMeasureName],'Date'[Date]=__last_noblank_date)
VAR __result = SWITCH(SELECTEDVALUE('Date'[Date]),__first_noblank_date,__first_noblank_value,__last_noblank_date,__last_noblank_value)
RETURN
__result

output:

vcgaomsft_0-1711073166734.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly--How to provide sample data in the Power BI Forum--China Power BI User Group

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @PMeadows ,

Please create a new measure like:

Measure = 
VAR __first_noblank_date = CALCULATE(FIRSTNONBLANK('Date'[Date],[YourMeasureName]),ALLEXCEPT('Table','Table'[Legend Field]))
VAR __last_noblank_date = CALCULATE(LASTNONBLANK('Date'[Date],[YourMeasureName]),ALLEXCEPT('Table','Table'[Legend Field]))
VAR __first_noblank_value = CALCULATE([YourMeasureName],'Date'[Date]=__first_noblank_date)
VAR __last_noblank_value = CALCULATE([YourMeasureName],'Date'[Date]=__last_noblank_date)
VAR __result = SWITCH(SELECTEDVALUE('Date'[Date]),__first_noblank_date,__first_noblank_value,__last_noblank_date,__last_noblank_value)
RETURN
__result

output:

vcgaomsft_0-1711073166734.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly--How to provide sample data in the Power BI Forum--China Power BI User Group

Thanks so much!

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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