The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Dear community,
I'm currently struggling with a DAX calculation. I've created the following DAX measure:
Hi @DLU ,
Based on your description, your need is to filter the data by situation and make totals.
You can try this:
Total Trans QTY LTM =
VAR _Date = MAX('Date'[Date])
VAR _Startdate = DATE(YEAR(_Date)-1,MONTH(_Date),DAY(_Date))
VAR _BOMitem = IF(SELECTEDVALUE('ITEMID BOM'[BOM version.BOMID])="Blank",1,0)
VAR _Workorder = FIND(SELECTEDVALUE('INVENTTRANS OUT MERGED'[REFERENCEID]),"WO",1,0)
VAR _FLAG = IF (__BOMitem = 1,1,IF(__Workorder=1,0,1))
VAR _Table = FILTER('INVENTTRANS OUT MERGED','INVENTTRANS OUT MERGED'[INVENTTRANS.DATEPHYSICAL]>=_Startdate &&_FLAG=1)
Return
SUMX(_Table,'INVENTTRANS OUT MERGED'[INVENTTRANS.QTY]*-1)
If that's not what you need, provide sample data and projected output.
Best Regards,
Gallen Luo
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Dear Gallen,
I've tried your suggestion but unfortunately it didn't give the right output, so like you requested hereby the sample data.
First the item table in which the BOMid is registered.
ITEMID | BOMID |
dog | "Blank" |
cat | B001 |
Then, the table in which the quantity is registered per referenceid.
ITEMID | REFERENCEID | QTY |
dog | WO1 | 5 |
dog | WO2 | 5 |
dog | IC01 | 5 |
dog | IC02 | 5 |
dog | SO1 | 5 |
dog | SO2 | 5 |
cat | WO3 | 5 |
cat | WO4 | 5 |
cat | IC03 | 5 |
cat | IC04 | 5 |
cat | SO3 | 5 |
cat | SO4 | 5 |
And finally, the numbers PowerBI should come up with.
ITEMID | QTY |
dog | 30 |
cat | 20 |
So just to summarize, if the bomid isn't empty I want to include all the quantities, except the ones that contain "WO" in the REFERENCEID. If the bomid is empty, I want to include all the quantities, so also "WO". I didn't elaborate on the maxdate function, because that's already doing what it should do.
Again, many thanks for you help!
Gr. Diana
User | Count |
---|---|
74 | |
70 | |
39 | |
30 | |
28 |
User | Count |
---|---|
104 | |
95 | |
51 | |
48 | |
46 |