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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. 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
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
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.