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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
HM615
Frequent Visitor

Filter table visual to show single row per value, according to other values in the source table.

In my source data, there are multiple rows per ID number. I have a simple table visual showing certain values that correspond to that ID number. I want to filter that visual so each ID number only appears once, according to specific criteria. I am pasting dummy sample data below to make this clearer. What I am looking for is the column B value for each ID in column A - however, I only want one single B value for each ID in column A, although my source data has multiple rows with multiple values. If column C is UF, that is the value I want. If there is no UF for a particular ID, then I want the max value that is in B. I have no idea how to do it! 

 

HM615_0-1725376595430.png

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1725423363307.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

expected result measure: =
VAR _partitionuf =
    FILTER (
        WINDOW (
            1,
            ABS,
            -1,
            ABS,
            ALL ( data ),
            ORDERBY ( data[value], DESC ),
            ,
            PARTITIONBY ( data[id] ),
            MATCHBY ( data[id], data[value], data[condition] )
        ),
        data[condition] = "uf"
    )
VAR _partitionall =
    WINDOW (
        1,
        ABS,
        1,
        ABS,
        ALL ( data ),
        ORDERBY ( data[value], DESC ),
        ,
        PARTITIONBY ( data[id] ),
        MATCHBY ( data[id], data[value], data[condition] )
    )
RETURN
    IF (
        COUNTROWS ( _partitionuf ) >= 1,
        MAXX ( _partitionuf, data[value] ),
        MAXX ( _partitionall, data[value] )
    )

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a measure.

 

Jihwan_Kim_0-1725423363307.png

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

expected result measure: =
VAR _partitionuf =
    FILTER (
        WINDOW (
            1,
            ABS,
            -1,
            ABS,
            ALL ( data ),
            ORDERBY ( data[value], DESC ),
            ,
            PARTITIONBY ( data[id] ),
            MATCHBY ( data[id], data[value], data[condition] )
        ),
        data[condition] = "uf"
    )
VAR _partitionall =
    WINDOW (
        1,
        ABS,
        1,
        ABS,
        ALL ( data ),
        ORDERBY ( data[value], DESC ),
        ,
        PARTITIONBY ( data[id] ),
        MATCHBY ( data[id], data[value], data[condition] )
    )
RETURN
    IF (
        COUNTROWS ( _partitionuf ) >= 1,
        MAXX ( _partitionuf, data[value] ),
        MAXX ( _partitionall, data[value] )
    )

 

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.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

BabyYoda
Frequent Visitor

Try this if you need a measure: 

Cleaned Column B Measure = Var ColA = SELECTEDVALUE(SampleTable[Column A])
Var HasUF = MAXX(FILTER(SampleTable, SampleTable[Column A]=ColA&&SampleTable[Column C]="UF"), SampleTable[Column B])
Var NoUF = MAXX(FILTER(SampleTable, SampleTable[Column A]=ColA), SampleTable[Column B])
 RETURN SWITCH(TRUE(), ISBLANK(HasUF), NoUF, HasUF)
 
or if you need a calculated column try this
Cleaned Column B = Var ColA = SampleTable[Column A]
Var HasUF = MAXX(FILTER(SampleTable, SampleTable[Column A]=ColA&&SampleTable[Column C]="UF"), SampleTable[Column B])
Var NoUF = MAXX(FILTER(SampleTable, SampleTable[Column A]=ColA), SampleTable[Column B])
 RETURN SWITCH(TRUE(), ISBLANK(HasUF), NoUF, HasUF)

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.