基本报表样式:
问题描述:
- 图表类型是 Table, 有3个切片器 Protocol ID、Site、Period 筛选数据
- 切片器 Protocol ID 和 Site 筛选确定 Chart显示的第一列 Subject。
chart显示的第二列 [ECG DataUpload] 是一个度量值,第三列 [ECG DataUpload Format] 也是一个度量值,将ECG DataUpload 进行格式化。DAX表达式如下:ECG DataUpload = VAR SelectedTenant = SELECTEDVALUE('TenantInformation'[Tenant]) VAR SelectedSites = VALUES('Relation_SiteTenant'[Site]) VAR SelectedPeriod = SELECTEDVALUE('Filter_PeriodTenant'[StatisticPeriod]) VAR StartDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodStart], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR EndDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodEnd], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR TempTable = ADDCOLUMNS( VALUES('Relation_SubjectSite'[Subject]), "ECGDataUpload", CALCULATE( SUM('DataUpload_Device_Subject-df'[amount]), FILTER('DataUpload_Device_Subject-df', 'DataUpload_Device_Subject-df'[Tenant] = SelectedTenant && 'DataUpload_Device_Subject-df'[Site] IN SelectedSites && 'DataUpload_Device_Subject-df'[Subject] = EARLIER('Relation_SubjectSite'[Subject]) && 'DataUpload_Device_Subject-df'[StatisticDate] >= StartDate && 'DataUpload_Device_Subject-df'[StatisticDate] <= EndDate ) ) ) RETURN SUMX(TempTable, IF(ISBLANK([ECGDataUpload]), 0, [ECGDataUpload]))
ECG DataUpload Format = VAR SelectedTenant = SELECTEDVALUE('TenantInformation'[Tenant]) VAR SelectedSites = VALUES('Relation_SiteTenant'[Site]) VAR SelectedPeriod = SELECTEDVALUE('Filter_PeriodTenant'[StatisticPeriod]) VAR StartDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodStart], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR EndDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodEnd], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR TempTable = ADDCOLUMNS( SUMMARIZE('Relation_SubjectSite', 'Relation_SubjectSite'[Subject], "ECGDataUpload", CALCULATE( SUM('DataUpload_Device_Subject-df'[amount]), FILTER('DataUpload_Device_Subject-df', 'DataUpload_Device_Subject-df'[Tenant] = SelectedTenant && 'DataUpload_Device_Subject-df'[Site] IN SelectedSites && 'DataUpload_Device_Subject-df'[StatisticDate] >= StartDate && 'DataUpload_Device_Subject-df'[StatisticDate] <= EndDate ) ) ), "TotalMinutes", IF(ISBLANK([ECGDataUpload]), 0, [ECGDataUpload]), "Days", INT(IF(ISBLANK([ECGDataUpload]), 0, [ECGDataUpload]) / 1440), "Hours", INT(MOD(IF(ISBLANK([ECGDataUpload]), 0, [ECGDataUpload]), 1440) / 60), "Minutes", MOD(IF(ISBLANK([ECGDataUpload]), 0, [ECGDataUpload]), 60) ) RETURN MAXX(TempTable, [Days] & " days " & [Hours] & " hours " & [Minutes] & " minutes")
- Chart显示第四列Rank也需要创建1个度量值,显示第一列Subject按照第二列度量值[ECG DataUpload]排名后的值。
但是,我目前创建的Rank表达式存在问题。要么是结果不正确,都是1. 要么是图表引入Rank后导致切片器 Protocol ID 和 Site的筛选失去作用,出现不符合筛选范围的Subject。
错误Rank示例Rank = VAR SelectedTenant = SELECTEDVALUE('TenantInformation'[Tenant]) VAR SelectedSites = VALUES('Relation_SiteTenant'[Site]) VAR SelectedPeriod = SELECTEDVALUE('Filter_PeriodTenant'[StatisticPeriod]) VAR StartDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodStart], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR EndDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodEnd], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR TempTable = ADDCOLUMNS( SUMMARIZE('Relation_SubjectSite', 'Relation_SubjectSite'[Subject], "ECGDataUpload", CALCULATE( SUM('DataUpload_Device_Subject-df'[amount]), FILTER('DataUpload_Device_Subject-df', 'DataUpload_Device_Subject-df'[Tenant] = SelectedTenant && 'DataUpload_Device_Subject-df'[Site] IN SelectedSites && 'DataUpload_Device_Subject-df'[StatisticDate] >= StartDate && 'DataUpload_Device_Subject-df'[StatisticDate] <= EndDate ) ) ), "TotalMinutes", IF(ISBLANK([ECGDataUpload]), 0, [ECGDataUpload]) ) RETURN IF(ISBLANK([ECG DataUpload]),BLANK(),RANKX(TempTable,MAXX(TempTable, [TotalMinutes]),,DESC,DENSE))
Rank = VAR SelectedTenant = SELECTEDVALUE('TenantInformation'[Tenant]) VAR SelectedSites = VALUES('Relation_SiteTenant'[Site]) VAR SelectedPeriod = SELECTEDVALUE('Filter_PeriodTenant'[StatisticPeriod]) VAR StartDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodStart], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR EndDate = LOOKUPVALUE('Filter_PeriodTenant'[PeriodEnd], 'Filter_PeriodTenant'[Tenant], SelectedTenant, 'Filter_PeriodTenant'[StatisticPeriod], SelectedPeriod) VAR TempTable = ADDCOLUMNS( SUMMARIZE( 'Relation_SubjectSite', 'Relation_SubjectSite'[Subject] ), "ECGDataUpload", CALCULATE( SUM('DataUpload_Device_Subject-df'[amount]), 'DataUpload_Device_Subject-df'[Tenant] = SelectedTenant && 'DataUpload_Device_Subject-df'[Site] IN SelectedSites && 'DataUpload_Device_Subject-df'[StatisticDate] >= StartDate && 'DataUpload_Device_Subject-df'[StatisticDate] <= EndDate ) ) VAR CurrentECGDataUpload = CALCULATE( SUM('DataUpload_Device_Subject-df'[amount]), 'DataUpload_Device_Subject-df'[Tenant] = SelectedTenant && 'DataUpload_Device_Subject-df'[Site] IN SelectedSites && 'DataUpload_Device_Subject-df'[Subject] = SELECTEDVALUE('Relation_SubjectSite'[Subject]) && 'DataUpload_Device_Subject-df'[StatisticDate] >= StartDate && 'DataUpload_Device_Subject-df'[StatisticDate] <= EndDate ) RETURN IF( ISBLANK(CurrentECGDataUpload), BLANK(), RANKX( TempTable, [ECGDataUpload], CurrentECGDataUpload, DESC, DENSE ) )
以上2个Rank,计算结果都有问题。Subject对应的值都是1。
求助内容
这种情景下,Rank这个度量值如何创建?实现下面的排名效果?
仗义每多屠狗辈!