Forum Discussion
SQL to DAX Convert
Hola
Soy nuevo en DAX, por favor ayuda a convertir el siguiente código T-SQL a su equivalnet DAX.
Estoy generando total de ejecución (cummulative) usando TSQL el mismo que necesito en DAX, por favor ayuda
select src.Final_date, sum([Units Assigned]) over(order by src.Final_date) as Final_cnt
from (
select [Received Date] as Final_date, count(CARGO_ID) as [Units Assigned] from dbo.table1 where
[Status]='ASSIGNED' and [Type]='TENDERED' and Dashboard='Inventory'
group by [Received Date]
) src
order by src.Final_date desc
Gracias de antemano
6 Replies
- amitchandakSuper User
@sarthaks , Probar como
sumx(values(Table[Received Date]), calculate(count(Table[CARGO_ID]),filter(Table, table[Status]-"ASSIGNED" && table[Type]-"TENDERED" && table[Dashboard]-"Inventory")))
- AnonymousNot applicable
No funciona.
No estoy obteniendo valores basados en la fórmula que usted ha proporcionado.
- v-yingjlCommunity Support
Hola @sarthaks ,
Intente utilizar esta fórmula para crear una tabla de cálculo y utilice 'Ordenar descendente' en la vista Datos:
A = VAR tab = SUMMARIZE ( FILTER ( 'dbo.table1', [Status] = "ASSIGNED" && [Type] = 'TENDERED' && [Dashboard] = 'Inventory' ), "Final_date", 'dbo.table1'[Received Date], "Units Assigned", COUNT ( 'dbo.table1'[CARGO_ID] ) ) RETURN SELECTCOLUMNS ( tab, "Final_cut", SUMX ( FILTER ( tab, [Final_date] <= MAX ( [Final_date] ) ), [Units Assigned] ) )Best Looks,
Yingjie LiSi este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.
- AnonymousNot applicable
Gracias por su respuesta! . Estoy teniendo problemas en este paso:
EVALUATE SUMMARIZE ( FILTER ( Inv_Fact_Inventory, Inv_Fact_Inventory[Dashboard]="Current Inventory" && Inv_Fact_Inventory[Inventory Status]="ASSIGNED" && Inv_Fact_Inventory[Inventory Order Type]="TENDERED NOT SHIPPED" ), , "Final_date", Inv_Fact_Inventory[Received Date], "Units Assigned", DISTINCTCOUNT(Inv_Fact_Inventory[CURINV_CARGO_ID]) )En Final_Date, a continuación se muestra el error
Siguiente cuando intento ejecutar toda la expresión im obteniendo el mismo valor para todos los registros. Me estoy perdiendo algo aquí..
Aquí está el código actualizado im usando ahora:
EVALUATE VAR tab = SUMMARIZE ( FILTER ( Inv_Fact_Inventory, Inv_Fact_Inventory[Dashboard]="Current Inventory" && Inv_Fact_Inventory[Inventory Status]="ASSIGNED" && Inv_Fact_Inventory[Inventory Order Type]="TENDERED NOT SHIPPED" ), Inv_Fact_Inventory[Received Date], "Units Assigned", DISTINCTCOUNT( Inv_Fact_Inventory[CURINV_CARGO_ID] ) ) RETURN SELECTCOLUMNS ( tab, "Final_cut", SUMX ( FILTER ( tab, Inv_Fact_Inventory[Received Date] <= MAX ( Inv_Fact_Inventory[Received Date] ) ), [Units Assigned] ) )Salida:
Por favor, aconseje
- v-yingjlCommunity Support
Hola @sarthaks ,
Modifique la fórmula de esta manera:
EVALUATE VAR tab = SUMMARIZE( FILTER( 'Inv_Fact_Inventory', 'Inv_Fact_Inventory'[Dashboard] = "Current Inventory" && 'Inv_Fact_Inventory'[Inventory Order Type] = "TENDERED" && 'Inv_Fact_Inventory'[Inventory Status] = "ASSIGNED" ), 'Inv_Fact_Inventory'[Received Date], "Units Assigned", CALCULATE(COUNT(Inv_Fact_Inventory[CURINV_CARGO_ID])) ) RETURN SELECTCOLUMNS( tab, "Final_Cut", var d = 'Inv_Fact_Inventory'[Received Date] return SUMX( FILTER( tab, [Received Date] <= d ), [Units Assigned] ) ) order by [Final_Cut] descUsted puede obtener su resultado esperado, a continuación está mi muestra y resultado:
Best Looks,
Yingjie LiSi este post ayuda, por favor considere Aceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.