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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anon46
Frequent Visitor

Aggregated table with various column aggregations

Hi all,

 

Sorry if there have been similar asks in the past but cant find the exact solution that I am looking for 🙂

 

I am trying to create a new aggregated table based on a specific value where all of the columns have a different function, then add additional columns to it. The purpose is to track a metric via the KPI visual.

 

This is an example of the current Order table:

ColorOrderHours Date
YellowA5Jan-22
YellowB10Jan-22
YellowA22Feb-22
BlueA11Jan-22
BlueA77Jan-22
BlueB5Jan-22
BlueA8Feb-22
BlueA15Mar-22

 

Expected Result: (only return aggregated columns when Order = A)

ColorCount of Order AAvg Hours DatePeriod (New)Period Goal (New)
Yellow15Jan-22P1<=3
Yellow122Feb-22P2<=4
Blue244Jan-22P1<=3
Blue18Feb-22P2<=4
Blue115Mar-22P2<=4

 

logic: 

step 1: calculate Period based on defined months (jan = P1, feb/mar = p2)
step 2: calculate Period goal based on Period column (p1 goal avg hrs<=3, p2 goal avg hrs<=4)
Step 3:if Order = A, then return group by "Color", count of "Order", average "Hours", "Period Goal"

1 ACCEPTED SOLUTION

Hi,

I am not sure if I understood your question correctly, but could you please try the below?

 

New AGG Table =
SUMMARIZE (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( 'Order', 'Order'[Order], 'Order'[Color], 'Order'[Date] ),
            "@CountOrders", CALCULATE ( COUNTROWS ( 'Order' ) ),
            "@AvgHrs", CALCULATE ( AVERAGE ( 'Order'[Hours] ) ),
            "@Date", FORMAT ( 'Order'[Date], "mmm yy" ),
            "@Period",
                IF (
                    'Order'[Date] >= DATE ( 2022, 2, 1 )
                        && 'Order'[Date] <= DATE ( 2022, 3, 31 ),
                    "P1",
                    "P2"
                ),
            "@PeriodGoal",
                IF (
                    'Order'[Date] >= DATE ( 2022, 2, 1 )
                        && 'Order'[Date] <= DATE ( 2022, 3, 31 ),
                    "<=3",
                    "<=4"
                )
        ),
        'Order'[Order] = "A"
    ),
    'Order'[Color],
    [@CountOrders],
    [@AvgHrs],
    [@Date],
    [@Period],
    [@PeriodGoal]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

3 REPLIES 3
Jihwan_Kim
Super User
Super User

Hi,

Please check the below DAX formula for creating a new table, and the attached pbix file.

 

New Agg Table = 
SUMMARIZE (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( 'Order', 'Order'[Order], 'Order'[Color], 'Order'[Date] ),
            "@CountOrders", CALCULATE ( COUNTROWS ( 'Order' ) ),
            "@AvgHrs", CALCULATE ( AVERAGE ( 'Order'[Hours] ) ),
            "@Date", FORMAT ( 'Order'[Date], "mmm yy" ),
            "@Period",
                IF (
                    MONTH ( 'Order'[Date] ) = 1,
                    "P1",
                    IF ( MONTH ( 'Order'[Date] ) = 2 || MONTH ( 'Order'[Date] ) = 3, "P2" )
                ),
            "@PeriodGoal",
                IF (
                    MONTH ( 'Order'[Date] ) = 1,
                    "<=3",
                    IF ( MONTH ( 'Order'[Date] ) = 2 || MONTH ( 'Order'[Date] ) = 3, "<=4" )
                )
        ),
        'Order'[Order] = "A"
    ),
    'Order'[Color],
    [@CountOrders],
    [@AvgHrs],
    [@Date],
    [@Period],
    [@PeriodGoal]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi @Jihwan_Kim thanks for the quick reply! 🙂 I would need to create date ranges for @Period so I have changed "month" to "datesbetween" but I am getting an "Argument '3' in IF statment required" error. Below is what I am looking for using P2 as an example. Thoughts?

 

New Agg Table =

SUMMARIZE (

    FILTER (

        ADDCOLUMNS (

            SUMMARIZE ( 'Order', 'Order'[Order], 'Order'[Color], 'Order'[Date] ),

            "@CountOrders", CALCULATE ( COUNTROWS ( 'Order' ) ),

            "@AvgHrs", CALCULATE ( AVERAGE ( 'Order'[Hours] ) ),

            "@Date", FORMAT ( 'Order'[Date], "mmm yy" ),

            "@Period",

                IF (

                     datesbetween('Order'[Date],DATE(2022,02,01),DATE(2022,03,31))= 1,

                    "P2",

                ),

            "@PeriodGoal",

                IF ((

                     datesbetween('Order'[Date],DATE(2022,02,01),DATE(2022,03,31))= 1,

                    "<=3",

                )

        ),

        'Order'[Order] = "A"

    ),

    'Order'[Color],

    [@CountOrders],

    [@AvgHrs],

    [@Date],

    [@Period],

    [@PeriodGoal]

)

Hi,

I am not sure if I understood your question correctly, but could you please try the below?

 

New AGG Table =
SUMMARIZE (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE ( 'Order', 'Order'[Order], 'Order'[Color], 'Order'[Date] ),
            "@CountOrders", CALCULATE ( COUNTROWS ( 'Order' ) ),
            "@AvgHrs", CALCULATE ( AVERAGE ( 'Order'[Hours] ) ),
            "@Date", FORMAT ( 'Order'[Date], "mmm yy" ),
            "@Period",
                IF (
                    'Order'[Date] >= DATE ( 2022, 2, 1 )
                        && 'Order'[Date] <= DATE ( 2022, 3, 31 ),
                    "P1",
                    "P2"
                ),
            "@PeriodGoal",
                IF (
                    'Order'[Date] >= DATE ( 2022, 2, 1 )
                        && 'Order'[Date] <= DATE ( 2022, 3, 31 ),
                    "<=3",
                    "<=4"
                )
        ),
        'Order'[Order] = "A"
    ),
    'Order'[Color],
    [@CountOrders],
    [@AvgHrs],
    [@Date],
    [@Period],
    [@PeriodGoal]
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors