PDA

View Full Version : How to recall a VBA function in Power Pivot Model?



codeghi
04-17-2022, 06:07 AM
HI,
I've created a VBA function ("FzFind") that works well in Excel, it's declared as shown below:



Function FzFind(lookup_value As String, tbl_array As Range) As String
Dim i As Integer, str As String, Value As String
Dim a As Integer, b As Integer, cell As Variant
...
...
End Function



The problem is that when I'm into the Power Pivot tool and I try to recall that function by typing "=" in a cell of a new column, that function doesn't appear.
So, how could I recall my function in Power Pivot so that I'm able to use it in a DAX formula?
Regards

Aussiebear
04-17-2022, 12:05 PM
As Understand it, you should be in Data View rather than Diagram View;
Click Tab of Data table
Click Add Button of Design Tab on Ribbon (This adds a new calculated column at end of current table}
Type = and enclose fields in Square Brackets ( e.g. =[Field A] * [Field B]
Hit Enter Key

p45cal
04-18-2022, 05:46 AM
see: https://social.msdn.microsoft.com/Forums/en-US/4058ef3f-3562-4800-aeb9-d9c9b2f44832/udf-and-powerpivot