Forum Discussion
Custom Matrix
- 2 years ago
Br1-981, thanks for the .pbix. I created 2 measures:
_Shares = VAR _selectedSumOfSales = SUMX( Sheet1, Sheet1[ Sales] ) VAR _selectedProduct = SELECTEDVALUE(Sheet1[Product]) VAR _totalSalesPerSegment = SUMX( FILTER( ALLSELECTED(Sheet1), Sheet1[Product] = _selectedProduct ), Sheet1[ Sales] ) RETURN DIVIDE(_selectedSumOfSales, _totalSalesPerSegment)_Sales&SharesFormatted = VAR _lineBreak = UNICHAR(10) VAR _sales = SUMX( Sheet1, Sheet1[ Sales] ) /*** Dynamic number formatting. Found here: https://community.fabric.microsoft.com/t5/Custom-Visuals-Ideas/Auto-Format-Numbers-in-Billions-Millions-Thousands-etc/idi-p/1439322 ***/ VAR _safeLog = IFERROR ( ABS(INT ( LOG ( ABS ( _sales), 1000 ) )), 0 ) VAR dp = 1 VAR _salesFormatted = ROUND ( DIVIDE ( _sales, 1000 ^ _safeLog ), dp ) & SWITCH ( _safelog, 1, "K", 2, "M", 3, "B", 4, "T" ) /***/ VAR _sharesFormatted = FORMAT([_Shares], "0.00%") RETURN _salesFormatted&_lineBreak&_sharesFormatted
I then placed [_Sales&SharesFormatted] as the only field in the Values well.You will want to play with the formatting in the [_Sales&SharesFormatted] measure.
If you need the sales in bold, this can be down using dynamic SVGs. I can help with this if needed. Otherwise, if this is enough to get you going please consider liking this reply and choosing it as the solution. Otherwise, I'm happy to help further.
Hi,
here you got a .pbix file made using a sample dataset from PBI
Thanks in advance for your support!
Br1-981, thanks for the .pbix. I created 2 measures:
_Shares =
VAR _selectedSumOfSales = SUMX(
Sheet1,
Sheet1[ Sales]
)
VAR _selectedProduct = SELECTEDVALUE(Sheet1[Product])
VAR _totalSalesPerSegment = SUMX(
FILTER(
ALLSELECTED(Sheet1),
Sheet1[Product] = _selectedProduct
),
Sheet1[ Sales]
)
RETURN DIVIDE(_selectedSumOfSales, _totalSalesPerSegment)
_Sales&SharesFormatted =
VAR _lineBreak = UNICHAR(10)
VAR _sales = SUMX(
Sheet1,
Sheet1[ Sales]
)
/***
Dynamic number formatting. Found here:
https://community.fabric.microsoft.com/t5/Custom-Visuals-Ideas/Auto-Format-Numbers-in-Billions-Millions-Thousands-etc/idi-p/1439322
***/
VAR _safeLog =
IFERROR ( ABS(INT ( LOG ( ABS ( _sales), 1000 ) )), 0 )
VAR dp = 1
VAR _salesFormatted = ROUND ( DIVIDE ( _sales, 1000 ^ _safeLog ), dp )
& SWITCH ( _safelog, 1, "K", 2, "M", 3, "B", 4, "T" )
/***/
VAR _sharesFormatted = FORMAT([_Shares], "0.00%")
RETURN _salesFormatted&_lineBreak&_sharesFormatted
I then placed [_Sales&SharesFormatted] as the only field in the Values well.
You will want to play with the formatting in the [_Sales&SharesFormatted] measure.
If you need the sales in bold, this can be down using dynamic SVGs. I can help with this if needed. Otherwise, if this is enough to get you going please consider liking this reply and choosing it as the solution. Otherwise, I'm happy to help further.
- Br1-9812 years agoHelper I
thanks a lot, I'll test asap and let you know about it!
In this scenario, do you think it is possible to format (font size and colour) the 2 values as showed in my example?