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
Anonymous
Not applicable

Indicate if row is TRUE()/FALSE() based on criteria of measure value

This is a follow up from the previous question (https://community.powerbi.com/t5/Desktop/Concatenate-rows-values-based-on-DAX-MEASURE-value/m-p/2667...)

I am trying to identify the [Step]s where if the cumulative total is < required balance AND also the first instance where the cumulative total is >= required balance


What I am trying to do is to find out for each specific product, what are the specific [Step] that I should focus on getting to completion and seek them out to meet my [Required balance].

Here [Product], [Step], [Quantity], [Required balance] is part of an actual column, while [Cumulative total] and [Cumulative total < Required balance] is a calculated measure. 

2 tables are involved here:
Required balance: [Product], [Required balance]
Quantity: [Product], [Step], [Quantity]

'Required balance'[Product] is linked to 'Quantity'[Product] in a one-to-many relationship.

 

ProductStepQuantityRequired balanceCumulative totalCumulative total < Required balance
A10127512True
A9717583False
A8127595False
A74875143False


Ideally my output should be:

 

ProductStepQuantityRequired balanceCumulative totalCumulative total < Required balanceTo be included
A10127512TrueTrue
A9717583FalseTrue
A8127595FalseFalse
A74875143FalseFalse


@MFelix 

 

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous ,

 

Based on the previous measures I have made try the following two measures:

Total cumulative vs required = [CUMULATIVE TOTAL] < SUM('Required Balance'[Required balance])


Steps Selected = 
VAR QuantityCumulative =
    ADDCOLUMNS (
        ALLSELECTED ( Quantity[Step] ),
        "@Quantity", [Quantity Value],
        "@CumulativeQuantity", [CUMULATIVE TOTAL]
    )
VAR QuantityBelowRequired =
    COUNTROWS (
        FILTER (
            QuantityCumulative,
            [@CumulativeQuantity] < SUM ( 'Required Balance'[Required balance] )
        )
    ) + 1
RETURN
        SELECTEDVALUE(Quantity[Step]) in SELECTCOLUMNS( TOPN ( QuantityBelowRequired, QuantityCumulative, [@CumulativeQuantity], ASC ), "Steps", Quantity[Step]
    )

MFelix_0-1659083835110.png

Attach PBIX file updated.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @Anonymous ,

 

Based on the previous measures I have made try the following two measures:

Total cumulative vs required = [CUMULATIVE TOTAL] < SUM('Required Balance'[Required balance])


Steps Selected = 
VAR QuantityCumulative =
    ADDCOLUMNS (
        ALLSELECTED ( Quantity[Step] ),
        "@Quantity", [Quantity Value],
        "@CumulativeQuantity", [CUMULATIVE TOTAL]
    )
VAR QuantityBelowRequired =
    COUNTROWS (
        FILTER (
            QuantityCumulative,
            [@CumulativeQuantity] < SUM ( 'Required Balance'[Required balance] )
        )
    ) + 1
RETURN
        SELECTEDVALUE(Quantity[Step]) in SELECTCOLUMNS( TOPN ( QuantityBelowRequired, QuantityCumulative, [@CumulativeQuantity], ASC ), "Steps", Quantity[Step]
    )

MFelix_0-1659083835110.png

Attach PBIX file updated.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Amazing... newfound appreciation for COUNTROWS()

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.