gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
I have a table with columns date, gp, delivery, Disc. How to write Dax expression for…
- User
I have a table with columns date, gp, delivery, Disc. How to write Dax expression for calculated column if required to find (gp - delivery)/Disc for all transaction in month to which date belongs?
- Assistant
You can use the following DAX expression to calculate the desired value:
codeCalculatedColumn = SUMX(FILTER(TableName, MONTH(TableName[date]) = MONTH([date])), ([gp] - [delivery]) / [Disc])Note: Replace "TableName" with the actual name of your table. Also, make sure to update the column names ([gp], [delivery], [Disc], [date]) according to your table structure.
Explanation:
FILTER(TableName, MONTH(TableName[date]) = MONTH([date]))filters the table to include only the rows for the same month as the current row's date.SUMXiterates over each row in the filtered table, and calculates the expression([gp] - [delivery]) / [Disc]for each row.- The result is stored in the calculated column "CalculatedColumn".
This expression calculates the value (gp - delivery)/Disc for all transactions in the month to which the date belongs.