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
DOLEARY85
Super User
Super User

Multiple Formats in a Single Column with Calculating Totals

Hi all, 

 

I recently needed to have multiple formats in a single field where the totals and sub totals would calculate within a matrix, I couldn't find anything that matched exactly what I needed and after some trial and error I came up with the solution, so I thought i'd share in case someone else has the same issue. 

 

In the table I had two quantity fields which needed to be whole numbers and three currency fields (Profit, Total Cost and Total Sales). The DAX Measure below uses CONTAINSSTRING & SELECTEDVALUE to search for the word ‘Profit’ or ‘Total’ within the Attribute and applies a format of currency to the Value field while retaining the ability to calculate the totals by using 'FORMAT & SUM', to all other fields it applies a whole number while again retaining the ability to calculate totals.

 

DAX Expression:

Value Measure For Multiple Data Formats = IF(OR(CONTAINSSTRING(SELECTEDVALUE(Table'[Attribute]),"Profit"),CONTAINSSTRING(SELECTEDVALUE('Table'[Attribute]),"Total")),FORMAT(SUM(Table'[Value])),"£#,##0.#0"),FORMAT(SUM('Table'[Value])),"#"))

 

If you're interested in why i needed to have multiple formats in one field check out my blog on the subject:  

https://github.com/DOLEARY85/Power-BI-Replicate-Excel-Table

 

1 ACCEPTED SOLUTION
DOLEARY85
Super User
Super User

This was just an information post

View solution in original post

2 REPLIES 2
DOLEARY85
Super User
Super User

This was just an information post

amitchandak
Super User
Super User

@DOLEARY85 , You have to work with total and Sub Total using isinscope and hasonevalue

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.