基于某些行的多列创建列 Power BI

问题描述 投票:0回答:1

我在 Power BI 中有下一张表

| Ubicación.Name     | Fecha_entrega__c | Sector_entrante__c |
| ------------------ | ---------------- | -------------------| 
| PAD FP.c-1050      | 5/31/2021        | Perforación        |
| PAD LAnch.x-2(h)   | 4/30/2022        | Terminación        | 
| PAD LAnch.x-2(h)   | 2/28/2022        | Perforación        |
| PAD LAnch.x-2(h)   | 7/13/2022        | Well Testing       | 
| PAD de Pozos 1003  | 4/23/2022        | Terminación        |  
| PAD de Pozos 1003  | 8/11/2022        | Perforación        | 

我想根据下一个逻辑创建一个专栏

对于“Ubicación.Name”中的某个组,例如“PAD LAnch.x-2(h)”,有三行这样的行,我想根据“Fecha_entrega__c”检查这些行是否是最新的”列,在“Sector_entrante__c”列中具有字符串“Well Testing”。在这种情况下,我们可以在第 4 行中看到第 2,3 行和第 4 行(所有这些都是“PAD LAnch.x-2(h)”的一部分)的最新日期,在“Sector_entrante__c”列中显示“Well Testing” ”,所以我想要一列为第 2,3 行和第 4 行提供数字 1。如果它没有“良好测试”,我想为第 2,3 行和第 4 行提供值 0。

| Ubicación.Name     | Fecha_entrega__c | Sector_entrante__c | Column |
| ------------------ | ---------------- | -------------------| -------|
| PAD FP.c-1050      | 5/31/2021        | Perforación        | 0      |
| PAD LAnch.x-2(h)   | 4/30/2022        | Terminación        | 1      |
| PAD LAnch.x-2(h)   | 2/28/2022        | Perforación        | 1      |
| PAD LAnch.x-2(h)   | 7/13/2022        | Well Testing       | 1      |
| PAD de Pozos 1003  | 4/23/2022        | Terminación        | 0      |  
| PAD de Pozos 1003  | 8/11/2022        | Perforación        | 0      |

谢谢。

我唯一能做的就是使用排名和过滤器来识别这些组中最新和最旧的数字

RANK Column = RANKX(FILTER('Form  NQN PAD Handover (3)','Form  NQN PAD Handover (3)'[Ubicación.Name]=EARLIER('Form  NQN PAD Handover (3)'[Ubicación.Name])),'Form  NQN PAD Handover (3)'[Fecha_entrega__c],,DESC)

但我真的不知道如何将逻辑应用于列中的某些组。

powerbi dax data-analysis powerbi-desktop calculated-columns
1个回答
0
投票

Column = 
VAR x = CALCULATE(MAX('Table'[Fecha_entrega__c]), ALLEXCEPT('Table', 'Table'[Ubicación.Name]))
VAR y = CALCULATE(MAX('Table'[Sector_entrante__c]), 'Table'[Fecha_entrega__c] = x, ALLEXCEPT('Table', 'Table'[Ubicación.Name]))

RETURN IF(y = "Well Testing", 1,0)
© www.soinside.com 2019 - 2024. All rights reserved.