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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
vishal097
Helper II
Helper II

Sum of Minimum QTY in each Category from Summarize Table

Hello Community,

I have requirement to get the sum of minimum QTY in each SFC (where it met the time target) in current filter context

I have data like 

vishal097_4-1662561970370.png

So to obtain this I have written a measure like 

vishal097_1-1662561306302.png

This was working fine until no other filter got used from report apart from SFC

but when User used other filter it gave incorrect result as 6 instead of 10

vishal097_3-1662561513156.png

Due to which my % calculate got incorrect as I have to use this value in Nominator

Reason to get 6 as result because in summarize it got only 6 values 

so I tried to add 3 more columns in Summarize as

vishal097_6-1662562305992.png

but this give sum of all QTY due to which I am getting duplicate values as there could be more that 1 record for same SFC

what solution I find for this is to get sum of minimum QTY in each SFC but from this Summarize table 

This is where I am not able to write measure.

Can someone please help.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @vishal097 
Please try

Units Produced Within Standard Time = 
SUMX (
    VALUES ( Fact_DailyMgmt_ThroughputTime_Detail[SFC] ),
    CALCULATE (
        MAXX (
            SUMMARIZE (
                Fact_DailyMgmt_ThroughputTime_Detail,
                Fact_DailyMgmt_ThroughputTime_Detail[SFC],
                Fact_DailyMgmt_ThroughputTime_Detail[START_TIME],
                Fact_DailyMgmt_ThroughputTime_Detail[END_TIME],
                Fact_DailyMgmt_ThroughputTime_Detail[Wait_Time_Type]
            ),
            CALCULATE (
                VAR QTY =
                    FIRSTNONBLANK ( Fact_DailyMgmt_ThroughputTime_Detail[QTY], 0 )
                VAR IsEligible =
                    IF (
                        SUM ( Fact_DailyMgmt_ThroughputTime_Detail[Throughput_Time] )
                            <= SUM ( Fact_DailyMgmt_ThroughputTime_Detail[ERP_Target] ),
                        1,
                        0
                    )
                RETURN
                    QTY * IsEligible
            )
        )
    )
)

View solution in original post

9 REPLIES 9
tamerj1
Super User
Super User

Hi @vishal097 
Please try

Units Produced Within Standard Time = 
SUMX (
    VALUES ( Fact_DailyMgmt_ThroughputTime_Detail[SFC] ),
    CALCULATE (
        MAXX (
            SUMMARIZE (
                Fact_DailyMgmt_ThroughputTime_Detail,
                Fact_DailyMgmt_ThroughputTime_Detail[SFC],
                Fact_DailyMgmt_ThroughputTime_Detail[START_TIME],
                Fact_DailyMgmt_ThroughputTime_Detail[END_TIME],
                Fact_DailyMgmt_ThroughputTime_Detail[Wait_Time_Type]
            ),
            CALCULATE (
                VAR QTY =
                    FIRSTNONBLANK ( Fact_DailyMgmt_ThroughputTime_Detail[QTY], 0 )
                VAR IsEligible =
                    IF (
                        SUM ( Fact_DailyMgmt_ThroughputTime_Detail[Throughput_Time] )
                            <= SUM ( Fact_DailyMgmt_ThroughputTime_Detail[ERP_Target] ),
                        1,
                        0
                    )
                RETURN
                    QTY * IsEligible
            )
        )
    )
)
tamerj1
Super User
Super User

Hi @vishal097 

you can nest MINX inside SUMX iterating twice over the summary table. Something like 

SUMX (

SummartTable1, -- without the aggregated columns 

CALCULATE ( 

MINX (

SummartTable2, -- with the aggregated columns 

[@Column1] * [@Column2]
)

)

)

 

Storing the summary table in a variable won't work die the need to apply context transition. 

Hello Tamer,

Thanks for looking into this as you suggested I have made the changes in code but not it showing 0 instead of actual values 

Units Produced Within Standard Time 2 =
VAR Result =
SUMMARIZE (
Fact_DailyMgmt_ThroughputTime_Detail,
Fact_DailyMgmt_ThroughputTime_Detail[SFC],
Fact_DailyMgmt_ThroughputTime_Detail[START_TIME],
Fact_DailyMgmt_ThroughputTime_Detail[END_TIME],
Fact_DailyMgmt_ThroughputTime_Detail[Wait_Time_Type]
)
VAR Result2 =
SUMMARIZE (
Fact_DailyMgmt_ThroughputTime_Detail,
Fact_DailyMgmt_ThroughputTime_Detail[SFC],
Fact_DailyMgmt_ThroughputTime_Detail[START_TIME],
Fact_DailyMgmt_ThroughputTime_Detail[END_TIME],
Fact_DailyMgmt_ThroughputTime_Detail[Wait_Time_Type],
"@QTY", FIRSTNONBLANK ( Fact_DailyMgmt_ThroughputTime_Detail[QTY], 0 ),
"@IsEligible",
IF ( SUM ( Fact_DailyMgmt_ThroughputTime_Detail[Throughput_Time] )
<= SUM ( Fact_DailyMgmt_ThroughputTime_Detail[ERP_Target] ),
1, 0
)
)
VAR R2 =
SUMX ( Result, CALCULATE ( MINX ( Result2, [@QTY] * [@IsEligible] ) ) )
RETURN
R2
 
also if I replace @IsEligible result as 1, blank() then i am getting sum of all QTY but we want some of min qty in each SFC as there are more than 1 record for one SFC

@vishal097 

I specifically I asked not to store the summary table in a variable. Please try

Units Produced Within Standard Time 2 =
SUMX (
    SUMMARIZE (
        Fact_DailyMgmt_ThroughputTime_Detail,
        Fact_DailyMgmt_ThroughputTime_Detail[SFC],
        Fact_DailyMgmt_ThroughputTime_Detail[START_TIME],
        Fact_DailyMgmt_ThroughputTime_Detail[END_TIME],
        Fact_DailyMgmt_ThroughputTime_Detail[Wait_Time_Type]
    ),
    CALCULATE (
        MINX (
            SUMMARIZE (
                Fact_DailyMgmt_ThroughputTime_Detail,
                Fact_DailyMgmt_ThroughputTime_Detail[SFC],
                Fact_DailyMgmt_ThroughputTime_Detail[START_TIME],
                Fact_DailyMgmt_ThroughputTime_Detail[END_TIME],
                Fact_DailyMgmt_ThroughputTime_Detail[Wait_Time_Type],
                "@QTY", FIRSTNONBLANK ( Fact_DailyMgmt_ThroughputTime_Detail[QTY], 0 ),
                "@IsEligible",
                    IF (
                        SUM ( Fact_DailyMgmt_ThroughputTime_Detail[Throughput_Time] )
                            <= SUM ( Fact_DailyMgmt_ThroughputTime_Detail[ERP_Target] ),
                        1,
                        0
                    )
            ),
            [@QTY] * [@IsEligible]
        )
    )
)

@tamerj1 

This work on filters apart from SFC

but when I select one particular SFC then should show Sum of Min QTY which will be same as 1

because we are calculating Min QTY in each SFC.

but instead of 1 it is showing some weird value as 11

Let know if you need more clarification on problem, will pinned you in message 

@vishal097 

Please try it this way

Units Produced Within Standard Time 2 =
SUMX (
    SUMMARIZE (
        Fact_DailyMgmt_ThroughputTime_Detail,
        Fact_DailyMgmt_ThroughputTime_Detail[SFC],
        Fact_DailyMgmt_ThroughputTime_Detail[START_TIME],
        Fact_DailyMgmt_ThroughputTime_Detail[END_TIME],
        Fact_DailyMgmt_ThroughputTime_Detail[Wait_Time_Type]
    ),
    CALCULATE (
        VAR QTY =
            FIRSTNONBLANK ( Fact_DailyMgmt_ThroughputTime_Detail[QTY], 0 )
        VAR IsEligible =
            IF (
                SUM ( Fact_DailyMgmt_ThroughputTime_Detail[Throughput_Time] )
                    <= SUM ( Fact_DailyMgmt_ThroughputTime_Detail[ERP_Target] ),
                1,
                0
            )
        RETURN
            QTY * @IsEligible
    )
)

@tamerj1 

 

This is giving same result as 11 for one perticular SFC instead of 1

however for other filter it is giving correct result.

@vishal097 

What is the code fro [Qty] & [is eligible]?

It is coming from same QTY column only thing is we are doing that that perticular row met the target in terms of time 

if met then in IsEligible it will give 1 or else 0 

so let's say if it met the target it will give 1 and in QTY it will give first nonblank QTY we are doing mutiplication so that we will get the same QTY

but if it does met target then it will become like 1*0 which will be 0 so this would not get count in calculation.

 

shall we connect over call so that I could better explain you the case

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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