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
Balaji1414
Frequent Visitor

Different data types in a single column

Hi All,

In my report i have a table and the data types are different (have $,%,text, numbers in a single column) in columns, i need to add a backround color for the data, any leads please

Many thanks in advance!

1 ACCEPTED SOLUTION

Hi @Balaji1414 ,

Sorry for delay. I updated my sample pbix file(see attachment), please check whether that is what you want.

Conditional formatting =
VAR _curcolumn =
SELECTEDVALUE ( 'Table'[Q1] )
VAR _includesc =
IFERROR ( SEARCH ( "$", _curcolumn, 1, 0 ), 0 )
VAR _scnumber =
IFERROR ( VALUE ( RIGHT ( _curcolumn, LEN ( _curcolumn ) - 1 ) ), 0 )
VAR _includepc =
IFERROR ( SEARCH ( "%", _curcolumn, 1, 0 ), 0 )
VAR _pcnumber =
IFERROR ( VALUE ( LEFT ( _curcolumn, LEN ( _curcolumn ) - 1 ) ) / 100, 0 )
VAR _number =
IFERROR ( VALUE ( _curcolumn ), 0 )
RETURN
SWITCH (
TRUE,
_includesc > 0,
IF ( _scnumber > 500, "#315496", IF ( _scnumber < 500, "#f6af82" ) ),
_includepc > 0, IF ( _pcnumber > 0.5, "#a9d092", "#ffff01" ),
IF ( _number > 75, "#00af50", IF ( _number < 50, "#fe0000" ) )
)

yingyinr_0-1628058631087.png

Best Regards

Community Support Team _ Rena
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

6 REPLIES 6
v-yiruan-msft
Community Support
Community Support

Hi @Balaji1414 ,

I created a sample pbix file(see attachment), please check whether that is what you want.

1. Create a measure as below to set the color for different type of data(include $,%,text, number etc.)

Note: You can change the color inside the formula to the color you want.

Conditional formatting = 
VAR _curcolumn =
    SELECTEDVALUE ( 'Table'[Column] )
VAR _includesc =
    IFERROR ( SEARCH ( "$", _curcolumn, 1, 0 ), 0 )
VAR _includepc =
    IFERROR ( SEARCH ( "%", _curcolumn, 1, 0 ), 0 )
VAR _number =
    IFERROR ( VALUE ( _curcolumn ), 0 )
RETURN
    IF (
        _includesc > 0,
        "red",
        IF ( _includepc, "orange", IF ( _number > 0, "purple", "green" ) )
    )

2. Make conditional formatting for background color of the column(Format by Field value)

Color based on a calculation

yingyinr_0-1627543134482.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
DataVitalizer
Super User
Super User

Hi @Balaji1414 ,

Could you share a screenshot of the column?

Balaji1414_0-1627902937657.png

Hi, column output shuld come like this

Hi @Balaji1414 ,

Sorry for delay. I updated my sample pbix file(see attachment), please check whether that is what you want.

Conditional formatting =
VAR _curcolumn =
SELECTEDVALUE ( 'Table'[Q1] )
VAR _includesc =
IFERROR ( SEARCH ( "$", _curcolumn, 1, 0 ), 0 )
VAR _scnumber =
IFERROR ( VALUE ( RIGHT ( _curcolumn, LEN ( _curcolumn ) - 1 ) ), 0 )
VAR _includepc =
IFERROR ( SEARCH ( "%", _curcolumn, 1, 0 ), 0 )
VAR _pcnumber =
IFERROR ( VALUE ( LEFT ( _curcolumn, LEN ( _curcolumn ) - 1 ) ) / 100, 0 )
VAR _number =
IFERROR ( VALUE ( _curcolumn ), 0 )
RETURN
SWITCH (
TRUE,
_includesc > 0,
IF ( _scnumber > 500, "#315496", IF ( _scnumber < 500, "#f6af82" ) ),
_includepc > 0, IF ( _pcnumber > 0.5, "#a9d092", "#ffff01" ),
IF ( _number > 75, "#00af50", IF ( _number < 50, "#fe0000" ) )
)

yingyinr_0-1628058631087.png

Best Regards

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

Hey thanks for your input, same way i have implemented it is working fine now. 
Here is another one if you can help that woud be great

I have built around 15 separate reports, all the reports are matrix (visual) data where I have displayed last 4quarters of data for each measure, I have defined BG color for the values based on the performance for each measure for the four quarters. Now I need to build a final report from all these 15 reports, I need to get the data from these measures where the measure performance is poor, bad (I have a logic) 

 

Pragati11
Super User
Super User

Hi @Balaji1414 ,

 

Not sure completly on what you are trying to ask here.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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!

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.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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