Forum Discussion

Noppadon's avatar
Noppadon
Frequent Visitor
5 years ago
Solved

How to Create Measure for Count by Condition

How to Create Measure for Count No. of Broken and No. of not Broken by Item Size Quantity Condition. In Case

CaseNo. of BrokenNo. of not Broken
All Size Quantity in Item as 000
Some Size Quantity in Item less than or equal 010
All Size Quantity in Item Quantity > 001

 

Example Result as attach Picture.

  • Anonymous's avatar
    Anonymous
    5 years ago

    HI Noppadon,

    Currently, Dax formulas not able to respond with common language condition strings.
    I think you need to wire measure formulas with switch function and trace current case, then you can write multiple expressions for different case calculate.

    Measure =
    VAR currCase =
        SELECTEDVALUE ( Table[Case] )
    RETURN
        SWITCH (
            currCase,
            "All Size Quantity in Item as 0", 'expression 1',
            "Some Size Quantity in Item less than or equal 0", 'expression 2',
            "All Size Quantity in Item Quantity > 0", 'expression 3',
            'default process'
        )
    

    Write Conditional Statement Using SWITCH in DAX and Power BI 

    Regards,

    Xiaoxin Sheng

3 Replies

  • Noppadon ,The information you have provided is not making the problem clear to me. Can you please explain with an example.
    Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
    Appreciate your Kudos.

    • Anonymous's avatar
      Anonymous
      Not applicable

      HI Noppadon,

      Currently, Dax formulas not able to respond with common language condition strings.
      I think you need to wire measure formulas with switch function and trace current case, then you can write multiple expressions for different case calculate.

      Measure =
      VAR currCase =
          SELECTEDVALUE ( Table[Case] )
      RETURN
          SWITCH (
              currCase,
              "All Size Quantity in Item as 0", 'expression 1',
              "Some Size Quantity in Item less than or equal 0", 'expression 2',
              "All Size Quantity in Item Quantity > 0", 'expression 3',
              'default process'
          )
      

      Write Conditional Statement Using SWITCH in DAX and Power BI 

      Regards,

      Xiaoxin Sheng