vba : elemete umverdichten (change consolidation)

    vba : elemete umverdichten (change consolidation)

    Hi there

    is there a way to change the consolidation of an element in a dimension by vba ? means: how can i delete the "Projekt 1" in the "Kategorie A" and add the element to the "Kategorie B" without loosing the data of the "Projekt 1" ?

    with edelete and eadd the data are lost:

    Paloret_1 = Application.Run("palo.enable_loop", True)

    Paloret_1 = Application.Run("palo.edelete", servert, "projekte", "Projekt 1")
    Paloret_2 = Application.Run("palo.eadd", servert, "Projekte", "N", "Projekt 1", "Kategorie B", 1, False)

    Paloret_1 = Application.Run("palo.enable_loop", False)

    thanks for help !
    hi hoger

    thanks for the tip

    i tried the excelformula =PALO.EUPDATE(servername;"projekte";"2044G";"N";{"Total Projekte";"2"}) without success (the cellvalue returns the value "True", but in the dimension nothing changes, neither a consolidation into the two parents "total projekte" and "2", nor a consolidation in "total Projekte" with fweightfactor 2.

    also no succsess in vba

    has anybody a better describtion/example for vba of this function ?
    Hi,
    he is code from element move via VBA

    Source Code

    1. Public Function eElementMove(sServer As String, sDimension As String, sElement As String, sOldParent As String, sNewParent As String, iWeight As Double) As Boolean
    2. res = Application.Run("PALO.ENABLE_LOOP", True)
    3. sType = Application.Run("PALO.ETYPE", sServer, sDimension, sElement)
    4. Select Case sType
    5. Case "consolidated"
    6. sType = "C"
    7. Case "numeric"
    8. sType = "N"
    9. Case "string"
    10. sType = "S"
    11. End Select
    12. Add = Application.Run("PALO.EADD", sServer, sDimension, sType, sElement, sNewParent, iWeight, False)
    13. Call PaloRemoveElementFromHierarchy(sServer, sDimension, sElement, sOldParent)
    14. res = Application.Run("PALO.ENABLE_LOOP", False)
    15. End Function
    16. Private Sub PaloRemoveElementFromHierarchy(sServer As String, sDimension As String, sElement As String, sParent As String)
    17. Dim result As Variant
    18. result = Application.Run("PALO.ELEMENT_LIST_CHILDREN", sServer, sDimension, sParent)
    19. If Not IsError(result) Then
    20. Dim children() As String, childIdx As Integer, resultIdx As Integer
    21. childIdx = 0
    22. ' If there is only one element in the result list, it has only one instead of two dimensions,
    23. ' fix that.
    24. EnsureTwoDimensionalResultArray result
    25. ' Create list of remaining children (alternating element name, consolidation factor)
    26. For resultIdx = LBound(result) To UBound(result)
    27. If result(resultIdx, 1) <> sElement Then
    28. ReDim Preserve children(childIdx + 1)
    29. children(childIdx) = result(resultIdx, 1)
    30. children(childIdx + 1) = result(resultIdx, 2)
    31. childIdx = childIdx + 2
    32. End If
    33. Next resultIdx
    34. If childIdx > 0 Then
    35. result = Application.Run("PALO.EUPDATE", sServer, sDimension, sParent, "C", children)
    36. Else
    37. ' special case if last child is removed
    38. ReDim children(1)
    39. children(0) = 0
    40. children(1) = 0
    41. result = Application.Run("PALO.EUPDATE", sServer, sDimension, sParent, "N", children)
    42. End If
    43. End If
    44. End Sub
    45. Private Sub EnsureTwoDimensionalResultArray(ByRef arr As Variant)
    46. Dim i As Integer
    47. On Error GoTo NotTwoDimensions
    48. i = LBound(arr, 2)
    49. Exit Sub
    50. NotTwoDimensions:
    51. Dim oneResultArray() As Variant
    52. ReDim oneResultArray(1 To 1, LBound(arr) To UBound(arr))
    53. For i = LBound(arr) To UBound(arr)
    54. oneResultArray(1, i) = arr(i)
    55. Next i
    56. arr = oneResultArray
    57. End Sub

    You must have a minimum version 2.5-3759 and higher

    see my topic for more information about VBA and PALO ;)
    jedox.com/community/palo-forum…?page=Thread&threadID=716