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 Br1-981, I'm not understanding what you're trying to achieve with the updated design, so it is difficult for me to identify how the measures I created for you would need to be updated. Could you help me understand what you'd like the new matrix to look like? Maybe a picture of the desired outcome would help. If you have an updated .pbix file, that'd help as well. Thanks!