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

Instance Tracking

Good Morning 

 

I have an excel work book with a VBA i need to move to Power BI. The code allows me to calcuate Instances of Absence. 

The Data is now in Power BI, this there away i can use the VBA in BI?

 

Current Excel VBA:

 

Sub Instance()
Dim sRange As Range
Dim cel As Range
Dim nextS As Range
Set sRange = Range("G2:AAJ900")
For Each cel In sRange.Cells
If cel.Value = "S" And cel.Offset(, 1).Value = "RTO" Then
With sRange.Rows(cel.Row - sRange.Cells(1).Row + 1)
Set c = .Find("S", LookIn:=xlValues, LookAt:=xlWhole)
Set c = .FindNext(cel)
If cel.Row = c.Row Then
If Application.CountIf(Range(cel, c), "RTO") = (Range(cel, c).Columns.Count - 2) Then
Range(cel.Offset(, 1), c.Offset(, -1)) = "S"
End If
End If
End With
End If
Next
End Sub

2 REPLIES 2
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your code, I think you can tell us about your logic and post some sample data(without sensitive data) and your expected result so that we can help you to achieve this in Power BI.

Thank you very much!

How to Get Your Question Answered Quickly 

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

You cannot use VBA in Power Query or Power BI. Recreate your code in M (the Power Query language) or DAX (the Power BI language)

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.