Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Noppadon
Frequent Visitor

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.1.jpg2.jpg3.jpg4.jpg

1 ACCEPTED SOLUTION

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
Noppadon
Frequent Visitor

I want to create 2 Measure for Count No. of Item. by Summary Quantity Condition. I Draft Example Output in pbix file as attach Link.

https://drive.google.com/file/d/1pl-SdqgVo0HwgcNJfESfP-CjU4t9dpg9/view?usp=sharing

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.