Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have been trying to convert this SQL case to Dax to work in Power Bi, but just can`t seem to find the right formula.
SELECT TOP(100) STOCKCODE, SUM(QUANTITY) as 'QUANTITY'
FROM (SELECT DI.STOCKCODE,
(CASE WHEN SI.CHKQTY = 'Y' THEN QUANTITY * NITS_PER_CARTON
ELSE QUANTITY
END) AS QUANTITY
FROM DI
JOIN SI
ON SI.STOCKCODE = DI.STOCKCODE
Any hints would be greatly appreciated.
Hi @kevinsray ,
You can create a calculated table Table1 first of all, then add index column in the Table1, and then create measure Sum for Quantity .
Table1 = SELECTCOLUMNS(FILTER(DI,DI[STOCKCODE]=MAX(SI[STOCKCODE])),"STOCKCODE",DI[STOCKCODE],"QUANTITY",IF(MAX(SI[CHKQTY] )= "Y",[QUANTITY] * [NITS_PER_CARTON],[QUANTITY] ))
Sum for Quantity = CALCULATE(SUM(Table1[QUANTITY]),FILTER(Table1,Table1[Index]<=100))
Best Regards,
Amy
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Amy,
Thank you for your help.
I am using the formula to create the table, but one small issue.
This QUANTITY * NITS_PER_CARTON calculation is actually from 2 different tables.
So, I guess I should have written DI.QUANTITY * SI.NITS_PER_CARTON
Is there any way to get around this?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |