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
Anonymous
Not applicable

Conversion of Excel formula to DAX

Hi,

 

I am struggling with a formula I need to convert from Excel to DAX. I have attached an image below of the sample data set, as well as the existing formula:

 

Sample dataset.png

 

=SUMPRODUCT(TEXT(TRIM(MID(SUBSTITUTE($B4&$G$4:$G$15;"%";REPT(" ";100));FIND($G$4:$G$15;SUBSTITUTE($B4&$G$4:$G$15;"%";REPT(" ";100)))+LEN($G$4:$G$15&"/");100));"0,000;0;0;\0")*($H$4:$H$15=B$19))/100

 

Basically, I have one table in PowerBI with a number of investor portfolios and their allocations towards a limited set of stocks, and another table with the total set of available stocks (with their region classification). 

 

What I need to do is to summarize each investor's allocation towards each region. All I need is the allocation in %, the amount in USD is irrelevant.

 

The problem for me, so far, seems to be that the "TEXT" function does not exist in DAX, and I have not been able to find a solution with alternative formulas. Please note, solving the problem using PowerQuery unfortunately is not an option in this case (for the purpose of the assignment, the solution needs to be purely in DAX, preferably as a measure rather than calculated column).

 

Thank you very much in advance. Will be happy to provide a sample workbook if preferred.

2 REPLIES 2
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Check this link: https://community.powerbi.com/t5/Desktop/Single-cell-stock-allocations/m-p/1054559#M493371



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Anonymous
Not applicable

Thanks Camargos,

 

Unfortunately, that solution relies on Power Query to do the calculations rather than a PowerPivot / DAX formula.

 

In this particular case that is unfortunately not an option.

 

Best,

Phil

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.