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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NKotak_Leecare
Helper III
Helper III

Measure for conditional formatting a card which displays count of incidents

Hi all,

 

I am looking to create a measure that I can use in conditional formatting of the accent bar to change color based on the incident value of the current month and the previous month. It should be a dynamic measure that returns the color red if the current month's count of incident saves is more than the previous month and green if it is less compared to last month.

 

The measure to calculate incident saves might need modification to show values just for the current month and not the entire date range. At present the measure looks like this:

 

IncidentSavesInSelectedInterval =
 
var x = CALCULATE(COUNT(IncidentForm[BatchID]))

return x
 
 
Thank you!!

 

6 REPLIES 6
Idrissshatila
Super User
Super User

Hello @NKotak_Leecare ,

 

you could use the following measure:

 

formatting =
SWITCH (
TRUE (),
[IncidentSavesInSelectedInterval] > [lastMonth], "#FF0000",
[IncidentSavesInSelectedInterval] < [lastMonth], "#008000"
)

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




Hi @Idrissshatila ,

 

I tried using this measure but it always returns red to me regardless of the difference. Also, I want to show blue if the last month's count and the current month's count are the same. So I modified the measure as below:

 

PreviousIncidentBar =
SWITCH (
TRUE (),
[NumberOfIncidents_New] > [LastMonth_Incident], "#FF0000",
[NumberOfIncidents_New] < [LastMonth_Incident], "#008000",
[NumberOfIncidents_New] = [LastMonth_Incident], "#0000FF"
)
 
LastMonth_Incident = CALCULATE([NumberOfIncidents_New],PARALLELPERIOD('date'[Date],-1,MONTH))
 
NumberOfIncidents_New =

//New Incident saves
//If BatchID = RecordID, denotes a new subform save, filtered by subform name, and returns NEW INCIDENTS ONLY in the selected time interval

var number = CALCULATE(COUNT(mainttable[batchid]),
                        FILTER(mainttable, mainttable[BatchID] = mainttable[RecordID]),
                        FILTER(maintable, maintable[FormName] = "IncidentFormName"))
return
if(ISBLANK(number),0,number)
 
Thank you!!

Thanks!

 

how are you getting [lastMonth]?

Hi @NKotak_Leecare 

 

You can do:

last Month= CALCULATE([IncidentSavesInSelectedInterval],PARALLELPERIOD([Date],-1,MONTH))

Hi @mlsx4 

 

Thank you! I tried using that measure but it is returning Red regardless of the count values. Do you have any idea why it is doing that and how can I resolve it?

Hi @NKotak_Leecare 

 

Have you checked which value returns each of your measure separately?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

April Fabric Community Update

Fabric Community Update - April 2024

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

March 2024 PBI Gallery Image

Power BI Monthly Update - March 2024

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