Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
carlm1975
Frequent Visitor

Creating a function within Power BI

Hi

 

I have a function I use in excel (I can post if you like but its quite a lot of text). Is there anyway I can call this in power BI or re-create this in Power BI. 

 

the basics of the function is to check if lat and long co-ords are within a reasonable area of the postcode.

 

Snippet of function:

 

Function testCoords(PC, IRCLat, IRCLong)

Dim OC(578) As String

Dim LatMax(578) As Double

Dim LatMin(578) As Double

Dim LongMin(578) As Double

Dim LongMax(578) As Double

 

 

OC(1) = "B1": LatMax(1) = 52.495956: LatMin(1) = 52.472609: LongMax(1) = -1.894214: LongMin(1) = -1.922561

OC(2) = "B10": LatMax(2) = 52.477985: LatMin(2) = 52.459173: LongMax(2) = -1.828649: LongMin(2) = -1.877087

OC(3) = "B11": LatMax(3) = 52.472108: LatMin(3) = 52.443094: LongMax(3) = -1.826494: LongMin(3) = -1.881428

 

testCoords = "Valid"

 

IRCOC = Left(PC, InStr(PC, " ") - 1)

OcIndex = 0

For X = 1 To 578

    If OC(X) = IRCOC Then OcIndex = X: X = 579

Next

If OcIndex = 0 Then

    testCoords = "Invalid Postcode"

    Exit Function

End If

If LatMax(OcIndex) < IRCLat Or LatMin(OcIndex) > IRCLat Or LongMax(OcIndex) < IRCLong Or LongMin(OcIndex) > IRCLong _

    Then testCoords = "Incorrect Lat/Long"

End Function

2 REPLIES 2
az2451
Resolver I
Resolver I

You may check out the DAX Function Reference

Thanks for the pointer but i still do not know where to start

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.