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
ACECEO
Regular Visitor

Issues Creating a 3 Column IF / Else in DAX Measure to Display the First Column that Has Data In It

I have a Power BI Report that contains many rows and each row has the same 3 address columns, displayed in the order below from left to right. 

 

  1. Home Address: Street
  2. Mailing Address: Street
  3. Business Address: Street

 

In each row, one or more of those columns may be populated with data.

 

Sometimes, the Home Address: Street is populated, but sometimes it's blank and the Mailing Address: Street is populated, in some cases both the Mailing Address: Street and Business Address: Street is populated, and agian sometimes only the Business Address Street is populated. 

 

I have a Dax Measure / Column named DAX Address Street and I need it to use the following logic:

 

  1. Look at Home Address: Street and if there is data present in that colum use that, and stop looking. 
  2. But, if Home Address: Street is blank, check the Mailing Address: Street column and if data is present there use that, and stop looking. 
  3. But if Mailng Address: Street is blank, then Check the Business Address: Street and if data is present there use that, but if that's blank too, then display the following text in the DAX Address Street Field "Client Does Not Have a Street Address On File".

 

Now, I wrote the following DAX Code, but even though it appears to be syntactically correct, it results in a gray screen with a memory error, even though I have 64 GB RAM on the machine that's running it. 

 

MemoryError.png

 

I am just getting into Power BI and DAX so I am certain I did something wrong. Hence, the reason I am here seeking guidance and assistance in determining what I need to do to achieve the objective listed above.

 

The report columns, DAX Code, and Desired Result I am seeking to achieve are shown in the image below. 

 

DAXSampleWithDesiredResult.png

 

 

RAW DAX Code is here in case it is needed: 

 

 

 

DAX Street Address = 
IF(
    ISBLANK(SELECTEDVALUE('Insured_Member_Dependents'[Home Address: Street])),
    
    IF(
        ISBLANK(SELECTEDVALUE('Insured_Member_Dependents'[Mailing Address: Street])),
            IF(
                ISBLANK(SELECTEDVALUE('Insured_Member_Dependents'[Business Address: Street])),
                    "Customer Does Not Have Any Address On File",
                SELECTEDVALUE('Insured_Member_Dependents'[Business Address: Street]
            )),
        SELECTEDVALUE('Insured_Member_Dependents'[Mailing Address: Street]
    )),
    SELECTEDVALUE('Insured_Member_Dependents'[Home Address: Street]
))

 

 

How can I achieve the objectve laid out above given the data I provided herein? 

 

Any help, guidance, suggestions, or advise would be greatly appreciated. 

 

 

 

1 ACCEPTED SOLUTION
ACECEO
Regular Visitor

I think I solved my own problem. I ended up using power query to get in front of the measure/dax code area, handling it at the pre-data set level as shown below. 

 

Table.AddColumn(#"Filtered Rows1", "PQ Address Street", each if [address2_line1] <> null
then [address2_line1]
else if [address3_line1] <> null 
then [address3_line1]
else if [address1_line1] <> null 
then [address1_line1]
else "NO CUSTOMER ADDRESS ON FILE")

View solution in original post

2 REPLIES 2
ACECEO
Regular Visitor

I think I solved my own problem. I ended up using power query to get in front of the measure/dax code area, handling it at the pre-data set level as shown below. 

 

Table.AddColumn(#"Filtered Rows1", "PQ Address Street", each if [address2_line1] <> null
then [address2_line1]
else if [address3_line1] <> null 
then [address3_line1]
else if [address1_line1] <> null 
then [address1_line1]
else "NO CUSTOMER ADDRESS ON FILE")

Nice - agree, Power Query is the best place to do this 🙂

Just offering an alternative syntax you may want to consider, using the null-coalescing operator (??):

Table.AddColumn(
    #"Filtered Rows1", "PQ Address Street", 
    each [address2_line1] ?? [address3_line1] ?? [address1_line1] ?? "NO CUSTOMER ADDRESS ON FILE"
)

 Regards


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

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

Top Kudoed Authors