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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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