Forum Discussion

nmhung49's avatar
nmhung49
Icon for Helper II rankHelper II
1 year ago
Solved

How to create measure to CALCULATE Qty_In

I’m having trouble with the CALCULATE function for Qty_In, which is incorrect when I select the current year and month. I want the result to display the farm org for the selected month and year, and Qty_In should be calculated with the condition that Document Type = 65. Please see the attached file for details. Attached File 

 

  • Hi nmhung49 

    You can test if there's a qty, then calculate where document type is 65. You can try this measure:

    IF.EAGER( SUM(factBreeder[QTY]) > 0, CALCULATE( SUM(factBreeder[QTY]), KEEPFILTERS(factBreeder[DOCUMENT_TYPE]   = 65), ALL('Calendar') ) )

5 Replies

  • Hi nmhung49 

    You can test if there's a qty, then calculate where document type is 65. You can try this measure:

    IF.EAGER( SUM(factBreeder[QTY]) > 0, CALCULATE( SUM(factBreeder[QTY]), KEEPFILTERS(factBreeder[DOCUMENT_TYPE]   = 65), ALL('Calendar') ) )
  • Sorry, if I add the Farm level into the matrix, the sum by farm is incorrect. Please help me edit the DAX again. Thanks!