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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
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

 

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

 

 

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (25)