Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by watching the DP-600 session on-demand now through April 28th.
Learn moreJoin the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now
Salida esperada - first_shoppers = 3083
Salida esperada - avg_spend_first_d = 134.53
Agregar datos de ejemplo:
| report_date | canal | membership_num | demand_revenue |
| 3/1/2023 | OPIC | 6923297 | 473.89 |
| 12/1/2022 | OPIC | 6923297 | 95.57 |
| 3/1/2023 | OPIC | 4732483 | 220.59 |
| 3/1/2023 | OPIC | 7968799 | 54.09 |
| 3/1/2023 | OPIC | 7707891 | 99.94 |
| 3/1/2023 | OPIC | 2953797 | 67.22 |
| 3/1/2023 | OPIC | 2119246 | 173.53 |
| 3/1/2023 | OPIC | 2159933 | 159.96 |
| 3/1/2023 | OPIC | 2276172 | 260.8 |
| 3/1/2023 | OPIC | 5549575 | 99.13 |
| 3/1/2023 | OPIC | 2109264 | 76.79 |
| 3/1/2023 | OPIC | 9386426 | 126.91 |
| 3/1/2023 | OPIC | 6798980 | 82.36 |
| 3/1/2023 | OPIC | 4165529 | 151.66 |
| 3/1/2023 | OPIC | 9276831 | 298.21 |
| 3/1/2023 | OPIC | 4771072 | 106.87 |
| 11/1/2022 | OPIC | 4771072 | 304.89 |
| 3/1/2023 | OPIC | 3956433 | 153.84 |
| 3/1/2023 | OPIC | 1650323 | 100.91 |
| 3/1/2023 | OPIC | 9976085 | 76.52 |
| 3/1/2023 | OPIC | 1061082 | 115.94 |
Datos completos
Tenemos que convertir esta consulta ORACLE SQL (abajo) de un sistema heredado a dax. Cada report_date es dinámico en el sistema heredado.
Esta consulta obtiene compradores por primera vez que solo realizaron un pedido en un rango especificado y que no han realizado ningún pedido 6 meses antes a partir del día de inicio, de ahí la parte MENOS 180.
¿Cómo puedo volver a escribir la consulta en DAX que incluye la sección MENOS de -180 que excluye a los compradores que realizaron un pedido en Power BI?
Aquí está la consulta:
@PowerBIET Debería ser algo en este sentido. Consulte PBIX adjunto debajo de la firma. Difícil de probar porque solo tiene un mes de datos.
First Shoppers =
VAR __DaysAgo = 180
VAR __MinRange = MIN('Table'[report_date])
VAR __TableRange1 = SUMMARIZE('Table',[membership_num],"__Count",COUNTROWS('Table'))
VAR __TableRange2 = FILTER(__TableRange1, [__Count] = 1)
VAR __PastRange = FILTER(ALL('Table'),[report_date] < __MinRange && [report_date] >= __MinRange - 180)
VAR __FirstShoppers = DISTINCT(SELECTCOLUMNS(__TableRange2,"__MemberNum",[membership_num]))
VAR __PastShoppers = DISTINCT(SELECTCOLUMNS(__PastRange,"__MemeberNum",[membership_num]))
VAR __MembersOfInterest =
EXCEPT(
__FirstShoppers,
__PastShoppers
)
VAR __Result = COUNTROWS(__MembersOfInterest)
RETURN
__Result
Average Spend =
VAR __DaysAgo = 180
VAR __MinRange = MIN('Table'[report_date])
VAR __TableRange1 = SUMMARIZE('Table',[membership_num],"__Count",COUNTROWS('Table'))
VAR __TableRange2 = FILTER(__TableRange1, [__Count] = 1)
VAR __PastRange = FILTER(ALL('Table'),[report_date] < __MinRange && [report_date] >= __MinRange - 180)
VAR __FirstShoppers = DISTINCT(SELECTCOLUMNS(__TableRange2,"__MemberNum",[membership_num]))
VAR __PastShoppers = DISTINCT(SELECTCOLUMNS(__PastRange,"__MemeberNum",[membership_num]))
VAR __MembersOfInterest =
EXCEPT(
__FirstShoppers,
__PastShoppers
)
VAR __Result = AVERAGEX(FILTER('Table', [membership_num] IN __MembersOfInterest),[demand_revenue])
RETURN
__Result
Check out the April 2026 Power BI update to learn about new features.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.