Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

SQL to DAX Convert

Hello,     I'm new to DAX, please help to convert below T-SQL code to its equivalnet DAX. I 'm generating running total (cummulative) using TSQL the same  i need in DAX, please help     selec...
  • v-yingjl's avatar
    v-yingjl
    6 years ago

    Hi Anonymous ,

    Modify the formula like this:

    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] desc

    You may get your expected result, below is my sample and result:

     

    Best Regards,
    Yingjie Li

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.