Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
check this
Public Sub SortDV
Set MyGraph = ActiveDocument.GetSheetObject("DynamicReport") 'Assigning the Chart to the variable MyGraph
Set MyDims = MyGraph.GetProperties.Dimensions 'Assigning the Chart Dimension Properties to the Variable MyDims
Set MyGraphProp = MyGraph.GetProperties 'Assigning the Chart Preoperties to the Variable MyGraphProp
set chart = ActiveDocument.GetSheetObject("DynamicReport")
set r = ActiveDocument.Variables("SortName")
set s = ActiveDocument.Variables("SortExpression")
set prop = chart.GetProperties
'prop.Dimensions(0).SortCriteria.SortByNumeric = 0
if s.GetContent.string = "Value" then
prop.Dimensions(0).SortCriteria.Expression.v = "=sum(Euros)"
else
prop.Dimensions(0).SortCriteria.Expression.v = "=sum(QtyKG)"
end if
if r.GetContent.string = "Desc" then
For i=0 to MyDims.Count - 1
prop.Dimensions(i).SortCriteria.SortByExpression = 1 'ascending
chart.SetProperties prop
r.SetContent "Asc", true
Next
else
For i=0 to MyDims.Count -1
prop.Dimensions(i).SortCriteria.SortByExpression = -1 'descending
chart.SetProperties prop
r.SetContent "Desc", true
Next
end if
end sub
'----------
take help from above macro
hope this helps
I am a New bee. So i could not get your answer. Could you please simplify it a bit ??
Hi
Hope this attached qv file will be helpful for you...
Here i use to sort the dimension using the expression. You can sort the table using sort propreties like text , orderwise, value.....
Just refer the attached qv file macro code.
Regards
Ashok
i dont have the licensed version of QlikView so i can not open this qvw file. Could u please post the macro that u have used ??
Hi
Sub Sort
set chart=ActiveDocument.GetSheetObject("CH01")
set Prop = chart.GetProperties
set vars = Prop.Dimensions
for i = 0 to vars.Count-1
vars.Item(i).SortCriteria.SortByLoadOrder = 0
vars.Item(i).SortCriteria.SortByAscii = 0
vars.Item(i).SortCriteria.SortByFrequency = 0
vars.Item(i).SortCriteria.SortByLoadOrder = 0
vars.Item(i).SortCriteria.SortByNumeric = 0
vars.Item(i).SortCriteria.SortByState = 0
vars.Item(i).SortCriteria.SortByExpression = 0
vars.Item(i).SortCriteria.Expression.v = ""
Next
chart.SetProperties Prop
'Set your Chart dimension and Set Expression Here .
sortExpression = "sum(Sales)"
sortDimention = Inputbox ("Enter the Dimenion to sort in Desending from 0 to "&vars.Count-1)
vars.Item(sortDimention).SortCriteria.SortByExpression = -1
vars.Item(sortDimention).SortCriteria.Expression.v = sortExpression
chart.SetProperties Prop
End Sub
Regards
Ashok
use below code
Sub SortChart
Set ch=ActiveDocument.GetSheetObject("CH01") ' You can change chartidd
Set p = ch.GetProperties
Set dims = p.Dimensions
'' Dimensions start by 0
'' 0 = Disable sort
'' 1 = Sort ascending
'' -1 = Sort descending
i = dims.Item(0).SortCriteria.SortByAscii
If i = 1 Then
dims.Item(0).SortCriteria.SortByAscii = -1
Else
dims.Item(0).SortCriteria.SortByAscii = 1
End If
ch.SetProperties p
End Sub
take one button add run this hoe this hels