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
Nexter
Advocate III
Advocate III

Question about upcoming feature, "Expression-Based Formatting"

Hi all,

 

I have a question about the upcoming Expression-Based Formatting feature.  The description reads as follows:

"Report authors need flexibility over how their visuals are formatted. As well as defining formatting through the formatting pane, a DAX expression can be used to set the formatting, giving full control over the business logic used to format the visual.

Authors can create rules that set the color of a KPI based on the progress towards a goal, set the style of a line on a chart based on which category is performing best, or any combination of these. Authors can even dynamically update the title of a visual based on selections made elsewhere in the report."

 

Do you all think this means I would be able to do a switch function, and designate the format (i.e. show as currency) in a visual with that switch function as a field?  So, if the measure containing the switch function has a general number format assigned, but within the switch function I say that one of the switch possibilities should be shown as currency, that when that option is selected it will show up in the visual as currency?  Or no matter what the visual will still only show the format that is selected as attached to the switch function measure?  I'm sorry if I'm not being very clear with this!  Let me know if I should explain it differently, thank you!!!!

3 REPLIES 3
v-juanli-msft
Community Support
Community Support

Hi @Nexter

The upcoming Expression-Based Formatting feature works for flexibily format the visual instead of the property of columns or values.

 

With this feature, you could write DAX formula to change the format (color, title, ect) of the visual according to your own requirement instead of selecting the limited items from the Format pane.

10.png

 

 

In fact, change the data format for a column is very easy to do, just select the "Modelling"->Data type  / Format.

If you need to do the transform like what you said above, here is a workaround.

 

Create a new table by Enter data

12.png

 

Create measures in the table

currency = FORMAT(SUM(Table1[number]),"Currency")

general = FORMAT(SUM(Table1[number]),"General Number")

Measure = IF(HASONEVALUE(Table2[switch]),
SWITCH(FIRSTNONBLANK(Table2[switch],Table2[switch]),
"currency",[currency],"general",[general]),
BLANK())

11.png

 

More details please read this article

But in this method, the measure is formated to be type of text.

 

 

Best Regards

Maggie

Hi Maggie,


Thanks for your reply.  However using the Format function converts it to text, correct?  Unfortunately this doesn't work for me since I would need to use this for a variety of visuals (column charts, line charts), not just matrixes and cards.  And in that case, I believe Format just wouldn't work.


I did however just find a proposed idea that seems to cover exactly what I'm looking for:

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/15231165-conditional-formatted-me...


I don't suppose you could think of a workaround for what's posted in the idea, right?  Thanks again for your response!



I know this question is a bit old, but one extension to Maggie's answer might be to default to returning the raw unformatted value if no specific formatting option is chosen.

 

eg

currency = FORMAT(SUM(Table1[number]),"Currency")

general = FORMAT(SUM(Table1[number]),"General Number")

raw = SUM( Table1[number] )

Measure = IF(HASONEVALUE(Table2[switch]),
             SWITCH(FIRSTNONBLANK(Table2[switch],Table2[switch]),
                    "currency",[currency],"general",[general]),
             [raw] )

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors