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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ianboothman84
Helper II
Helper II

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
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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.