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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
mterry
Helper V
Helper V

Creating a new table based on multiple criteria evaluations with DAX

I have a data table and would like to create a new table based on multiple criteria (if it's possible to do this by grouping or modifying the existing table that's fine as well). In the new table I want to summarize by the Office Column and Subcategory column and have a third column that either has 'Yes', 'No', or 'N/A' in it. If the Attribute column is First and the Percentage is 0, then the new 3rd column  should be 'N/A', otherwise for each Subcategory I need to have the Percentage amount for the row with the Second value in the Attribute column subtract the Percentage amount for the row with the First value in the Attribute column and the resulting value is greater than or equal to 0, the new third column in the new table should say 'Yes', otherwise 'No'.  Below is a sample of the data with a fourth (unneccessary) explanation column to help show the desired result.

 

OfficeSubcategoryAttributePercentageDesired Result w/Explanation
1ABFirst0%'N/A' - Percentage for First is 0%
1ABSecond0%
1ABCFirst10%'Yes' - Percentage for Second - Percentage for First is 0
1ABCSecond10%
1ABCDFirst10%'No' - Percentage for Second - Percentage for First is <0
1ABCDSecond5%
2ABFirst10%'Yes' - 20%-10%>=0
2ABSecond20%
2ABCFirst0%'N/A' - 0% for First
2ABCSecond-10%
2ABCDFirst10%'No' - 0%-10%<0
2ABCDSecond0%

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @mterry 

 

You can try the following methods.

Column =
VAR _first =
    CALCULATE (
        MIN ( 'Table'[Percentage] ),
        FILTER (
            'Table',
            [Subcategory] = EARLIER ( 'Table'[Subcategory] )
                && [Attribute] = "First"
                && [Office] = EARLIER ( 'Table'[Office] )
        )
    )
VAR _second =
    CALCULATE (
        MIN ( 'Table'[Percentage] ),
        FILTER (
            'Table',
            [Subcategory] = EARLIER ( 'Table'[Subcategory] )
                && [Attribute] = "Second"
                && [Office] = EARLIER ( 'Table'[Office] )
        )
    )
RETURN
    IF ( _first = 0, "N/A", IF ( _second - _first >= 0, "Yes", "No" ) )

vzhangti_0-1653894741804.png

Table:

New table =
SUMMARIZE ( 'Table', 'Table'[Office], 'Table'[Subcategory], 'Table'[Column] )

vzhangti_2-1653894917726.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @mterry 

 

You can try the following methods.

Column =
VAR _first =
    CALCULATE (
        MIN ( 'Table'[Percentage] ),
        FILTER (
            'Table',
            [Subcategory] = EARLIER ( 'Table'[Subcategory] )
                && [Attribute] = "First"
                && [Office] = EARLIER ( 'Table'[Office] )
        )
    )
VAR _second =
    CALCULATE (
        MIN ( 'Table'[Percentage] ),
        FILTER (
            'Table',
            [Subcategory] = EARLIER ( 'Table'[Subcategory] )
                && [Attribute] = "Second"
                && [Office] = EARLIER ( 'Table'[Office] )
        )
    )
RETURN
    IF ( _first = 0, "N/A", IF ( _second - _first >= 0, "Yes", "No" ) )

vzhangti_0-1653894741804.png

Table:

New table =
SUMMARIZE ( 'Table', 'Table'[Office], 'Table'[Subcategory], 'Table'[Column] )

vzhangti_2-1653894917726.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mterry
Helper V
Helper V

I realize that including the desired result can be a bit confusing as it doesn't show the actual layout I'm seeking - this would be the actual final output:

 

OfficeSubcategoryCol 3
1ABNA
1ABCYes
1ABCDNo
2ABYes
2ABCN/A
2ABCDNo

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.