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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
crUzo
New Member

replace null values with distinct values from channel using DAX only

INPUT-
 
| channel | code
|----------|----------|
| SMS | Sent |
| SMS | Del |
| WA | Sent |
| WA | Del |
| Email | Sent |
| Email | Del |
|(null) | UEF |
 
OUTPUT-
 
| channel | code
|----------|----------|
| SMS | Sent |
| SMS | Del |
| WA | Sent |
| WA | Del |
| Email | Sent |
| Email | Del |
|SMS | UEF |
|WA | UEF |
|Email | UEF |
5 REPLIES 5
v-sshirivolu
Community Support
Community Support

Hi @crUzo ,
Thanks for reaching out to the Microsoft fabric community forum.

I’ve gone ahead and reproduced your scenario in Power BI, and I’m glad to confirm that the output matches exactly as per your expected result. The logic successfully replaces the null values in the channel column by generating new rows with all distinct non-null channel values for the given code.

For your reference, below is the DAX I used to create the final output table:

daxCopyEditFinalTable =
VAR __channels =
    FILTER( DISTINCT( 'Table'[channel] ), [channel] <> BLANK() )
VAR __nullCodes =
    DISTINCT( SELECTCOLUMNS( FILTER( 'Table', [channel] = BLANK() ), "code", [code] ) )
VAR __BaseTable =
    FILTER( 'Table', [channel] <> BLANK() )
VAR __AddTable =
    SELECTCOLUMNS(
        GENERATE( __channels, __nullCodes ),
        "channel", [channel],
        "code", [code]
    )
VAR __Result =
    UNION( __BaseTable, __AddTable )
RETURN
    __Result

 

I've also attached the .pbix file for your reference so you can check and test the setup directly in your environment.

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it

Best Regards,
Sreeteja
Community Support Team.

Hi @crUzo ,

Just wanted to check if you had the opportunity to review the suggestion provided?

If the response has addressed your query, please Accept it as a solution and give a 'Kudos' so other members can easily find it.

 

Thank you.

 

Greg_Deckler
Super User
Super User

@crUzo Maybe:

Table1 = 
  VAR __Channels = FILTER( DISTINCT( 'Table'[channel] ), [channel] <> BLANK() )
  VAR __nullCodes = DISTINCT( SELECTCOLUMNS( FILTER( 'Table', [channel] = BLANK() ), "code", [code] ) )
  VAR __BaseTable = FILTER( 'Table', [channel] <> BLANK() )
  VAR __AddTable = SELECTCOLUMNS( GENERATE( __Channels, __nullCodes ), "channel", [channel], "code", [code] )
  VAR __Result = UNION( __BaseTable, __AddTable )
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
ajaybabuinturi
Solution Supplier
Solution Supplier

Hi @crUzo

Could you please provide more details about your request so that it's easy to understand. The provided deatails are not enough to address. 

I want to replace null values from channed to SMS, WA and EMAIL in front for UEF in code

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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