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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Solution Supplier
Solution Supplier

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

November Carousel

Fabric Community Update - November 2024

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

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.