Forum Discussion
How do I set certain conditions for Card visuals?
- 5 years ago
Hi Anonymous
Download sample PBIX file with code/visuals shown below
What code are you using to create the current card visual?
Looking at your screenshots the Status column is text so presumaby this contains things like "Open" and "Closed" ?
OK so we don't know how you are calculating the number of open tickets but I'm guessing it will be something like this
Open Tickets = CALCULATE(COUNTROWS(RequestDetails), FILTER('RequestDetails', 'RequestDetails'[Status] = "Open"))which returns a number.
I'm assuming that in the images above the text Open Tickets is the Category Label for the card? In which case you need to turn this off so the card just displays a number
Now we can alter the Open Tickets measure to account for 0/Blank, 1 or more than 1 open tickets.
Open Tickets = VAR _OpenTickets = CALCULATE(COUNTROWS(RequestDetails), FILTER('RequestDetails', 'RequestDetails'[Status] = "Open")) RETURN SWITCH( TRUE(), _OpenTickets = 0, "No Open Tickets", _OpenTickets = 1, "1 " & UNICHAR(00010) & "Open Ticket", _OpenTickets & UNICHAR(00010) & " Open Tickets" )Regards
Phil
Hi Anonymous
Download sample PBIX file with code/visuals shown below
What code are you using to create the current card visual?
Looking at your screenshots the Status column is text so presumaby this contains things like "Open" and "Closed" ?
OK so we don't know how you are calculating the number of open tickets but I'm guessing it will be something like this
Open Tickets = CALCULATE(COUNTROWS(RequestDetails), FILTER('RequestDetails', 'RequestDetails'[Status] = "Open"))
which returns a number.
I'm assuming that in the images above the text Open Tickets is the Category Label for the card? In which case you need to turn this off so the card just displays a number
Now we can alter the Open Tickets measure to account for 0/Blank, 1 or more than 1 open tickets.
Open Tickets =
VAR _OpenTickets = CALCULATE(COUNTROWS(RequestDetails), FILTER('RequestDetails', 'RequestDetails'[Status] = "Open"))
RETURN
SWITCH(
TRUE(),
_OpenTickets = 0, "No Open Tickets",
_OpenTickets = 1, "1 " & UNICHAR(00010) & "Open Ticket",
_OpenTickets & UNICHAR(00010) & " Open Tickets"
)
Regards
Phil
- Anonymous5 years agoNot applicable
PhilipTreacy Big thank you that worked, I think it was because I had label turned on. My mistake.
Can I ask just one quick question though? Other then "Open" I have two other values that go into the "Open" count. "Waiting on Customer" and "Waiting on Vendor" how do I put that into the Open count in that code? I've just tried adding it in but the Visual refuses to appear.- PhilipTreacy5 years agoSuper User
No worries Anonymous
To include other Status as Open change the FILTER in the VAR line to this
VAR _OpenTickets = CALCULATE(COUNTROWS(RequestDetails), FILTER('RequestDetails', 'RequestDetails'[Status] IN {"Open", "Waiting on Customer", "Waiting on Vendor"}))Regards
Phil
- Anonymous5 years agoNot applicable
Thanks very much Phil, very helpful!