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
Anonymous
Not applicable

Switch True

Hi   

 

I am working on an power bi report, I have two columns with the time stamp, one is for  when an opreater scans in to the device and one for when they have scanned out.  Im not sure if the Switch True Function is the fountion that I need. But I would like to have a visual that will turn  green if they are logged into the decive and red it they are not. Is that possible? 

9 REPLIES 9
amitchandak
Super User
Super User

@Anonymous , not very clear. But you can create a color measure. and use that using "Field value"  option conditional formatting 

example measure

Color  = if(FIRSTNONBLANK(Table[Year],2014) <=2016 && AVERAGE(Sales[Sales Amount])<170 
,"lightgreen",if(FIRSTNONBLANK(Table[Year],2014)>2018,"red","yellow"))
Color sales = if([Sales Today] -[sales yesterday]>0,"green","red")

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"
)

 

 

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

 

 

icon formatting
https://exceleratorbi.com.au/conditional-formatting-using-icons-in-power-bi/
https://community.powerbi.com/t5/Desktop/FORMAT-icon-set-for-use-in-a-data-card/td-p/811692

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
Anonymous
Not applicable

I dont know any other way to explain it, and dont think that example is what I'm looking for 

Anonymous
Not applicable

I just want to know the status of the device base on the time stamp columns, green if its on red if its off.

parry2k
Super User
Super User

@Anonymous not fully clear what you are trying to achieve, paste some sample data, and expected output. Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



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.

Anonymous
Not applicable

In the picture below are the start and end time for different devices. I want to know is it possible to create a visual using the SwitchTrue() function, that will change colors if someone has scanned in or out of that device 

 

Jlivenere-25_0-1598455534669.png

 

hi  @Anonymous 

This a "start date and end date" problem, very common, you could refer to this similar post:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Periodic-Billing/m-p/409365

 

If you still have problem, please share some simple sample data and what your expected output like.

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

I think im al most there, how do you create a measure that turn a True column into ones and zeros

hi  @Anonymous 

Share some simple sample data and your expected output, that will be a great help.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

 

Hi 

 

Sorry for the delay, here basically what I wanted, I have a column that has  "Acttive" or "Inactive". I worte an if statement that add a new column with 1's and 0's (what you see in the picture). If that value is 1 then the color with be Green to let me know that machine is active.  I wanted the DeviceName to change colors if the device was active or not. But this is the best solution I could come up with . 

 

Jlivenere-25_0-1600107717887.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!

November Carousel

Fabric Community Update - November 2024

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

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.