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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
hbgv123
Frequent Visitor

Repeat text in a new calculated column based on conditions

Hi,

I am kind of stuck in this simple issue. I thought of using (calculate max all except) to arrive at the solution but somehow text values are not recognized. Can you please check this issue. I am so used to LOD min condition in tableau.

Current structure

ProductCountryRep
FurnituresUSRep-1
FurnituresCARep-2
FurnituresGBRep-3
FurnituresFRRep-4
FurnituresITRep-5
ElectronicsGBRep-11
ElectronicsCARep-21
ElectronicsUSRep-31
ElectronicsFRRep-41
ElectronicsITRep-51

 

 

Expected output with calculated column Lead (DAX)

Lead is updated based on rep for each product from Country US

ProductCountryRepLead
FurnituresUSRep-1Rep-1
FurnituresCARep-2Rep-1
FurnituresGBRep-3Rep-1
FurnituresFRRep-4Rep-1
FurnituresITRep-5Rep-1
ElectronicsGBRep-11Rep-31
ElectronicsCARep-21Rep-31
ElectronicsUSRep-31Rep-31
ElectronicsFRRep-41Rep-31
ElectronicsITRep-51Rep-31
    

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @hbgv123 ,

 

you can add a calculated column like:

Column = 
MAXX(
    FILTER(
        data,
        data[Product]=EARLIER(data[Product])
            &&data[Country]="US"
    ),
    data[Rep]
)

 

it worked like:

FreemanZ_0-1707383911050.png

 

View solution in original post

2 REPLIES 2
govindarajan_d
Super User
Super User

Hi @hbgv123 ,

 

Explanation: We use FILTER function to create a virtual table that contains Rep for each Product's US Rep. Then we use the FIRSTNONBLANK function to get the value of the Rep. You can think of it as a MIN or MAX for text. 

 

 

Lead =
VAR __Product = Data[Product]
VAR __Result =
    FIRSTNONBLANK (
        SELECTCOLUMNS (
            FILTER ( ALL ( Data ), Data[Country] = "US" && Data[Product] = __Product ),
            "Lead", Data[Rep]
        ),
        [Lead]
    )
RETURN
    __Result

 

 

govindarajan_d_1-1707385276068.png

 

 

FreemanZ
Super User
Super User

hi @hbgv123 ,

 

you can add a calculated column like:

Column = 
MAXX(
    FILTER(
        data,
        data[Product]=EARLIER(data[Product])
            &&data[Country]="US"
    ),
    data[Rep]
)

 

it worked like:

FreemanZ_0-1707383911050.png

 

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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

Top Solution Authors