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 II

## Display last N points in different color based on timestamp

Hi all,

I have a table like this with a live data connection,

Timestamp       Value1        Value2

16/06/2020 1:00    10        3

16/06/2020 2:00    12        23

16/06/2020 3:00    4         11

16/06/2020 4:00     2            5

I have plotted a scatterplot with Value1 vs Value2. As the timestamp increases the density of the scatterplot increases. Therefore, i would like to show the last N values in a different color.

For ex, if value1 vs value2 is plotted in blue color, lets say N is 2. I want (4,11) and (2,5) to be displayed in red color. This should be possible for different N values. N represents the number of values to be shown from the last timestamp.

Could someone help me on this. Thanks

1 ACCEPTED SOLUTION
Community Support

Based on your dsecription, I created data with live connection to reproduce your scenario.

Tab:

You may create a measure as below.

``````Rank =
RANKX(
ALL(Tab),
CALCULATE(SUM(Tab[Timestamp]))
)``````

You may make the visual selected, go to 'Visualizations', click 'Format'=>'Data coclors', click conditional formatting for the visual, set as below.

Result:

Best Regards

Allan

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

5 REPLIES 5
Community Support

Based on your dsecription, I created data with live connection to reproduce your scenario.

Tab:

You may create a measure as below.

``````Rank =
RANKX(
ALL(Tab),
CALCULATE(SUM(Tab[Timestamp]))
)``````

You may make the visual selected, go to 'Visualizations', click 'Format'=>'Data coclors', click conditional formatting for the visual, set as below.

Result:

Best Regards

Allan

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helper II

Hi @v-alq-msft ,

Thanks for the solution. This almost solves my problem. But the only issue is, you are putting rank>2 in the conditional format. In a live connection, there will be many timestamps coming in. In that case there will be a lot of points after rank 2.

So, for example if there are 10 rows also, i want to show the last 2 rows only. I hope there is some way to solve that. Thanks

Community Support

The rankx  function sorts by timestamps from hign to low by default. So you can set the rule as 'if [Rank]<=2 then red' to show the last two rows only.

Best Regards

Allan

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helper II

This measure isnt workin @v-alq-msft . It shows an error

Super User

@pbidemouser2 , Create a measure that return color based on codition

example:

``````Color sales = if(AVERAGE(Sales[Sales Amount])<170,"green","red")
Color Year = if(FIRSTNONBLANK(Table[Year],2014) <=2016,"lightgreen",if(FIRSTNONBLANK(Table[Year],2014)>2018,"red","yellow"))

color =
switch ( true(),
FIRSTNONBLANK(Table[commodity],"NA") ="commodity1" && sum(Table[Value]) >500,"lightgreen",
FIRSTNONBLANK(Table[commodity],"NA") ="commodity2" && sum(Table[Value]) >1000,"lightgreen",
/// Add more conditions
"red"
)``````

You have use sum of value1 or value 2.

Then in data in data color use fx - conditional formatting. In that choose field option and color measure

refer for steps

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