Search code examples
powerbidaxdaxstudio

Filter the measure based on the other measure value(Without using the Sumx Function)


Please help me I am trying to filter the data in 23 Qty Blank measure Based on the check Month Wise .

Check Month Wise = IF(ISBLANK([23 Qty]),"D",IF(ISBLANK([22 Qty]),"N","V"))

This is Measure. I have tried this dax 23 Qty Blank = If( check Month Wise="V", 23 Qty,0) But its not working subtotal level its getting item code level only .

Please find the attached link for Image

This is which I am expected result [23 Qty Blank] By using the sumx function which i am getting ,But i need without using the Sumx is it possible to filter the data?

23 Qty Blank = SUMX(SUMMARIZE('Financial Data (3)','Financial Data (3)'[Group],'Financial Data (3)'[SEGMENT],'Financial Data (3)'[PRODUCT CATEGORY],'Financial Data (3)'[CORPORATE CUSTOMER],'Financial Data (3)'[REPORTING COUNTRY],'Financial Data (3)'[PAC ITEM CODE],"Final",if(Check Month Wise = "V",[23 Qty],0)),[Final])

Please find the attached link for Expected Result Image


Solution

  • Here is an approach without using SUMX.

    23 Qty (had 22) = 
      var tbl22 = 
        SELECTCOLUMNS(
          FILTER(
            SUMMARIZE('Financial Data Month',
              'Financial Data Month'[REPORTING COUNTRY],
              'Financial Data Month'[SEGMENT],
              'Financial Data Month'[PAC ITEM CODE],
              "Total", [22 QTY],
              "ID", [REPORTING COUNTRY] & "/" & [SEGMENT] & "/" & [PAC ITEM CODE]
            ),
            NOT ISBLANK([Total])
          ),
          [ID]
        )
      
      return
        CALCULATE(
          [23 Qty],
          'Financial Data Month'[REPORTING COUNTRY] & "/" & 'Financial Data Month'[SEGMENT] & "/" & 'Financial Data Month'[PAC ITEM CODE] IN tbl22
        )
    

    Basically, it's getting all that exist in y22, and then return their y23 values.

    You will need to add any additional columns above to ensure they are unique. In other words, add all that are used in Rows of your Matrix.