将Pivot过滤器设置为第一个可用值 [英] Set Pivot filter to first available value

查看:77
本文介绍了将Pivot过滤器设置为第一个可用值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这更像是一个VBA问题,但具体针对SSAS,所以在此发布。我正在寻找可以帮助
的VBA代码将透视滤镜中的字段的过滤器设置为第一个可用值。 
数据透视表基于
a SSAS模型。




当我录制宏时,这就是我得到的ABC是透视滤镜中的第一个元素。我无法想象
如何使它成为泛型,即使用类似于使用PivotFields.Items(1)

 ActiveSheet.PivotTables(" PivotTable1")。PivotFields(_ 
" [Org]。[Account]。[Account]")。ClearAllFilters
ActiveSheet.PivotTables(" PivotTable1")。 PivotFields(_
" [Org]。[Account]。[Account]")。CurrentPage = _
" [Org]。[Account]。& [ABC]"






解决方案


我们可以引用特定数据透视字段的数据范围并获取单元格的第一个值。以下是供您参考的示例:

 Sheet1.PivotTables(1).PivotFields(" name")。 DataRange.Cells(1)

关心&费


This is more of a VBA question but specific to SSAS so posting here. I'm looking for VBA code that can help set the filter for a field in a pivot filter to the first available value. Pivot table is based on a SSAS model.

When I record a macro, this is what I get where ABC is the first element in the pivot filter. I'm not able to figure out how to make it generic i.e. use something like using PivotFields.Items(1)

ActiveSheet.PivotTables("PivotTable1").PivotFields( _
        "[Org].[Account].[Account]").ClearAllFilters
    ActiveSheet.PivotTables("PivotTable1").PivotFields( _
        "[Org].[Account].[Account]").CurrentPage = _
        "[Org].[Account].&[ABC]"



解决方案

Hi,

We can refer to the data range of the specific pivot field and get the first value of cells. Here is an example for your reference:

Sheet1.PivotTables(1).PivotFields("name").DataRange.Cells(1)

Regards & Fei


这篇关于将Pivot过滤器设置为第一个可用值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆