cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ianboothman84
Helper I
Helper I

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, @ianboothman84 

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 III
Super User III

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
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are You Ready?

Test your skills now with the Cloud Skills Challenge.

Top Solution Authors