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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
robertnoble
Regular Visitor

Conditional Formating Matrix Comparing Previous Column

Hi,

 

I have the following matrix, the top row represents story points (as a bucket) and AVG time in days (measure). (The data is off due to missing data, but working to get that fixed).

robertnoble_0-1698948031016.png

I want to add icon conditional formating in such a way that if the previous bucket is larger, to put a warning icon and if it is larger than the previous bucket, put a green icon.

 

e.g. since 13's is only 3 days and 10 is 22 days, 13 value would show a warning sign. Whereas 20 would show green since 22 is larger than 3.

 

The final logic of the conditional formating seems straight forward, if() argument comparing values and returns 1 or 0 and then assign those to an icon.

 

My issue is in creating the measure, I cannot get it to calculate the value of the previous bucket to compare.

 

Conditional formatting = 
VAR storypoint =
    SELECTEDVALUE ( 'Issue Data'[Story Points] )
VAR currentstory =
    CALCULATE([Pt AVG Final], FILTER('Issue Data','Issue Data'[Story Points] = storypoint)
    )

VAR PTSum =
    addcolumns(
        SUMMARIZE('Issue Data', 'Issue Data'[Story Points]),
        "By Point",
        [Pt AVG Final]
    )
var prevpt =
    CALCULATE(MINx(topn(2,PTSum,'Issue Data'[Story Points]),'Issue Data'[Story Points]), ALL('Issue Data'), 'Issue Data'[Story Points])

var previousstory = CALCULATE([Pt AVG Final], Filter('Issue Data', 'Issue Data'[Story Points] = prevpt)

return
if(currentstory > previousstory, 1, 0)

 

My issue is that when trying to derive prevpt, it will return the same story point value instead of the the one below it (i.e. For 20, it should return 13, not 20 which it is doing now). Not sure if there is an issue with PTSum due to the slicers, although when I check DAX Studio, it seems to work correctly.

 

Also, if you know a better way to do this please do share. I was looking for various other ways to do this, but most other examples involve dates so it is a lot easier pulling previous month data but the reference here are numeric buckets (Story Points).

3 REPLIES 3
parry2k
Super User
Super User

@robertnoble I would recommend sharing pbix file using one drive/google drive and removing any sensitive information before sharing. Also, please explain the expected output.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@robertnoble try this:

 

Conditional formatting = 
VAR currentstory = [Pt AVG Final]
VAR PTSum =
    addcolumns(
        SUMMARIZE(ALLSELECTED('Issue Data'[Story Points] ), 'Issue Data'[Story Points]),
        "By Point",
        [Pt AVG Final]
    )
var prevpt =
    MINx(topn(2,PTSum,'Issue Data'[Story Points]),'Issue Data'[Story Points])

var previousstory = CALCULATE([Pt AVG Final], 'Issue Data'[Story Points] = prevpt)

return
if(currentstory > previousstory, 1, 0)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Did not work. Looks like it is ignoring my filters and also prevpt is returning 73 for each story point bucket and causing (blank) for the previoustory. Applying it to the visual gets this:

robertnoble_0-1698957755895.png

 

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!

December 2024

A Year in Review - December 2024

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