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
kokos88
New Member

DAX measure to filter only one row with lowest number per customer

Hi,

 

I have such dataset:

 

CustomerReasonAmountRow Number
1A71
1B152
1C353
2B131
2C92
2D223
3C11
3A242
3B173

 

I have added filter: "Reason" to the report (values are: A, B, C, D).

 

I need measure which calculates SUM of Amount column for all customers, but it should only take one row per customer - with the lowest number of "Row Number".

 

Let's imagine: I have choosen on "Reason" slicer: B and C. So my measure should take only (values in orange in above table):

For Customer 1, Amount: 15 - because the lowest Row Number is 2 - for "Reason" B,

For Customer 2, Amount: 13 - because the lowest Row Number is 1 - for "Reason" B,

For Customer 3, Amount: 1 - because the lowest Row Number is 1 - for "Reason" C

 

So total value of this measure is 15 + 13 + 1 = 29

 

Can anybody help me with this? Thank you!

 

9 REPLIES 9
v-kathullac
Community Support
Community Support

Hi @kokos88 ,

 

Thank you for reaching out to Microsoft Fabric Community.

I hope the below screenshot will solve your issue .

vkathullac_0-1753185314311.png

Attaching the pbix file for your refrence let me know if you need any further assistance.

 

Thanks.

 

rohit1991
Super User
Super User

Hi @kokos88 ,
Heres a DAX measure that will return the sum of Amount per customer, only for the row with the lowest "Row Number" (after applying any Reason filter):

Sum of Amount - Lowest Row per Customer = 
SUMX(
    VALUES('Table'[Customer]),
    VAR MinRow = CALCULATE(
        MIN('Table'[Row Number])
    )
    RETURN
        CALCULATE(
            SELECTEDVALUE('Table'[Amount]),
            'Table'[Row Number] = MinRow
        )
)

Replace 'Table' with your actual table name.

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Thank you for you solution. It works 🙂

I have one more question... when I create table with customer and reason - sum of values from all rows is different than the measure you created. 
Any idea what filter I can add to the visual to only show one row for customer? So, to show only rows highlighted in green?

kokos88_1-1752489661402.png

 




Hi @kokos88,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Thank you @rohit1991 and @techies for the prompt response.

 

To also make the table visual to show only one row per customer, create a helper measure that filters out all other rows like below:

Show Lowest Row Only =

VAR MinRow =

    CALCULATE(

        MIN('Table'[Row Number]),

        ALLEXCEPT('Table', 'Table'[Customer]),

        KEEPFILTERS('Table'[Reason])

    )

RETURN

    IF('Table'[Row Number] = MinRow, 1, 0)

 

Add this measure to your table and apply a visual level filter like Show Lowest Row Only is 1

Now the table shows only the row with the lowest Row Number for each customer and the sum will match the measure result like the green rows which are highlighted.

 

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

 

Thanks and regards,

Anjan Kumar Chippa

Hi,

Thank you! When I try to add this measure there is error message:

A single value for column 'Row Number' in table 'Table' cannot be determined. This can happen when a measure or function formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

Hi @kokos88 

 

To always show only the row with the lowest Row Number per customer (after Reason slicer/filter), add this measure to your table:

Show Lowest Row Only =
VAR ThisCustomer = 'Table'[Customer]
VAR MinRow =
    CALCULATE(
        MIN('Table'[Row Number]),
        FILTER(
            ALLSELECTED('Table'),
            'Table'[Customer] = ThisCustomer
        )
    )
RETURN
    IF('Table'[Row Number] = MinRow, 1, 0)

 

Then, add this measure to your table visual and set a visual-level filter to Show Lowest Row Only = 1. This should update correctly with your Reason slicer and always keep only the lowest row per customer.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

Thank you for your response!

Unfortunately the solution doesn't work...

When I did as you proposed the table shows different value than expected - one row is missing. 

I have selected in slicer Reason B and C

 

kokos88_0-1752825218028.png

 

There should be additional 1 row (highlighted in green). But column isLowestRow is 0 for this case, that's why it is not present

 

kokos88_1-1752825361182.png

 

techies
Super User
Super User

Hi @kokos88 please try this

 

Sum_Lowest_RowPerCustomer =
SUMX(
    VALUES(DATAS[Customer]),
    VAR CustomerID = DATAS[Customer]
    VAR MinRow =
        CALCULATE(
            MIN(DATAS[Row Number]),
            DATAS[Customer] = CustomerID
        )
    RETURN
        CALCULATE(
            SUM(DATAS[Amount]),
            DATAS[Customer] = CustomerID,
            DATAS[Row Number] = MinRow
        )
)
― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

Thank you for you solution. It works 🙂

I have one more question... when I create table with customer and reason - sum of values from all rows is different than the measure you created. 
Any idea what filter I can add to the visual to only show one row for customer? So, to show only rows highlighted in green?

kokos88_1-1752489661402.png

 




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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.