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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DeeA
Frequent Visitor

Dax measure. Ignore blanks/nulls in comparing columns

Hello,
Please i want to write a calculated column (Moved_Static in below) to indicate movement across cities per misisdn. and also number of occurences of the movement.

This is what i drafted 

Moved_Static =

IF(
NOT(ISBLANK(locations_v2[1/1/2023]))=NOT(ISBLANK(locations_v2[2/1/2023]))&&
NOT(ISBLANK(locations_v2[2/1/2023]))=NOT(ISBLANK(locations_v2[3/1/2023]))&&
NOT(ISBLANK(locations_v2[3/1/2023]))=NOT(ISBLANK(locations_v2[4/1/2023]))&&
NOT(ISBLANK(locations_v2[4/1/2023]))=NOT(ISBLANK(locations_v2[5/1/2023]))&&
NOT(ISBLANK(locations_v2[5/1/2023]))=NOT(ISBLANK(locations_v2[6/1/2023]))&&
NOT(ISBLANK(locations_v2[6/1/2023]))=NOT(ISBLANK(locations_v2[7/1/2023]),
"Static",
"Moved")

 

 

and this is the result i get in the last column.

msisdn_key1/1/20232/1/20233/1/20234/1/20235/1/20236/1/20237/1/2023Moved_Static
3333333City1City1City1City1City1City1 Moved
5555555City3City3City3City3 City3 Moved
7777777City4City4City5City5 City5 Moved
8888888City6City6 City6City6City6 Moved
9999999 City7 City7City8City9 Moved

 

 

but i want t ignore the nulls and get this below;

msisdn_key1/1/20232/1/20233/1/20234/1/20235/1/20236/1/20237/1/2023Moved_Static
3333333City1City1City1City1City1City1 Static
5555555City3City3City3City3 City3 Static
7777777City4City4City5City5 City5 Moved
8888888City6City6 City6City6City6 Moved
9999999 City7 City7City8City9 Moved

 

Please help

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@DeeA add new calculated column using the following expression

 

Moved - Static = 
VAR __MoveCount =
COUNTROWS ( 
    FILTER ( 
        DISTINCT ( 
            { 
                'Move'[1/1/2023],
                'Move'[2/1/2023],
                'Move'[3/1/2023],
                'Move'[4/1/2023],
                'Move'[5/1/2023],
                'Move'[6/1/2023],
                'Move'[7/1/2023]
            }
        ),
        [Value] <> BLANK ( ) 
    )
)
RETURN
IF ( __MoveCount > 1, "Moved " & FORMAT ( __MoveCount, "###" ) & " times", "Static" )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

You have got a calculated column formula answer which is great.  In my opinion, you should first use the "Unpivot Other Columns" feature to transform your dataset into a 3 column one.  This will make it easier for your to answer the question that you have and do truck loads of other analysis with a lot of ease.  Just in case you do not want to use the "Unpivot Other columns" feature, you may use this M code to generate another column

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMoYAJR0l58ySSkMSaKVYnWglUwiAChvjoZGZIJ3mEAAVNkGjTZFoZCZIpwUEQIXNkGgsQnApkE5LCECoNEdlgmiYuWBVsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [msisdn_key = _t, #"01-01-2023" = _t, #"02-01-2023" = _t, #"03-01-2023" = _t, #"04-01-2023" = _t, #"05-01-2023" = _t, #"06-01-2023" = _t, #"07-01-2023" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each if List.Count(List.Distinct(List.Select(List.Skip(Record.ToList(_),1), each _<>"")))=1 then "Static" else "Moved")
in
    #"Added Custom"

Hope this helps.

Ashish_Mathur_0-1692843057591.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur thanks for your feedback.

the dataset was initially a 3 column one and i pivoted to get it in the format i shared because it looked easier to answer the question i had. i am however open to trying a solution with the 3 column dataset to answer my question of showing the movement across the cities over the past months.

thannks

Hi,

Once you have a 3 column table, you may just drag the msisdn_key to the visual and write this measure

Measure = if(distinctcount(Data[Date])>1,"Moved","Statuc")

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@DeeA blank value and an empty string are two different things, my formula is checking a blank (aka null) value, not an empty string. Maybe tweak it like this:

 

Moved - Static = 
VAR __MoveCount =
COUNTROWS ( 
    FILTER ( 
        DISTINCT ( 
            { 
                'Move'[1/1/2023],
                'Move'[2/1/2023],
                'Move'[3/1/2023],
                'Move'[4/1/2023],
                'Move'[5/1/2023],
                'Move'[6/1/2023],
                'Move'[7/1/2023]
            }
        ),
        COALESCE ( [Value], "" ) <> ""
    )
)
RETURN
IF ( __MoveCount > 1, "Moved " & FORMAT ( __MoveCount, "###" ) & " times", "Static" )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

parry2k
Super User
Super User

@DeeA add new calculated column using the following expression

 

Moved - Static = 
VAR __MoveCount =
COUNTROWS ( 
    FILTER ( 
        DISTINCT ( 
            { 
                'Move'[1/1/2023],
                'Move'[2/1/2023],
                'Move'[3/1/2023],
                'Move'[4/1/2023],
                'Move'[5/1/2023],
                'Move'[6/1/2023],
                'Move'[7/1/2023]
            }
        ),
        [Value] <> BLANK ( ) 
    )
)
RETURN
IF ( __MoveCount > 1, "Moved " & FORMAT ( __MoveCount, "###" ) & " times", "Static" )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

DeeA
Frequent Visitor

Thanks for this!

so for the areas where there were blanks it indicates inactivity. how will incorporate that into the measure. so that for something like below i can indicate the months of inactivity

 

msisdn_key1/1/20232/1/20233/1/20234/1/20235/1/20236/1/20237/1/2023Moved_Static
3333333City1City1City1City1City1City1 Moved
5555555City3City3City3City3 City3 Moved
7777777City4City4City5City5 City5 Moved
8888888City6City6 City6City6City6 Moved
9999999 City7 City7City8City9 Moved

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors