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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
pbidemouser2
Helper II
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
v-alq-msft
Community Support
Community Support

Hi, @pbidemouser2 

 

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

Tab:

a1.png

 

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.

a2.png

 

a3.png

 

Result:

a4.png

 

Best Regards

Allan

 

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

View solution in original post

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @pbidemouser2 

 

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

Tab:

a1.png

 

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.

a2.png

 

a3.png

 

Result:

a4.png

 

Best Regards

Allan

 

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

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

Hi, @pbidemouser2 

 

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.

 

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

amitchandak
Super User
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

https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.