Skip to main content
cancel
Showing results for 
Search instead 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

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

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors