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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mahsy
Helper I
Helper I

Replace null by 0 in matrix

Hi,

 

I need your help please !

 

This is what i want :

mahsy_0-1641914273191.png

 

This is what i get :

mahsy_1-1641914338737.png

I would like to display all values and replace null by 0.

 

Thank you for your help !

 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @mahsy 

 

Try this measure:

Sum_Measure =
VAR _A =
    ADDCOLUMNS (
        CROSSJOIN ( VALUES ( 'Table'[Axel] ), VALUES ( 'Table'[AX2] ) ),
        "M1",
            CALCULATE (
                SUM ( 'Table'[Measure] ),
                FILTER (
                    'Table',
                    'Table'[Axel] = EARLIER ( [Axel] )
                        && 'Table'[AX2] = EARLIER ( [AX2] )
                )
            ) + 0
    )
VAR _B =
    SUMX ( _A, [M1] )
RETURN
    _B

 

the output:

VahidDM_0-1641943406571.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

3 REPLIES 3
VahidDM
Super User
Super User

Hi @mahsy 

 

Try this measure:

Sum_Measure =
VAR _A =
    ADDCOLUMNS (
        CROSSJOIN ( VALUES ( 'Table'[Axel] ), VALUES ( 'Table'[AX2] ) ),
        "M1",
            CALCULATE (
                SUM ( 'Table'[Measure] ),
                FILTER (
                    'Table',
                    'Table'[Axel] = EARLIER ( [Axel] )
                        && 'Table'[AX2] = EARLIER ( [AX2] )
                )
            ) + 0
    )
VAR _B =
    SUMX ( _A, [M1] )
RETURN
    _B

 

the output:

VahidDM_0-1641943406571.png

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

ValtteriN
Super User
Super User

Hi,

You can use IF + ISBLANK to achieve this. Example:
DAX: 

NullToZero = IF(ISBLANK(SUM(NullToZero[Data])),0,SUM(NullToZero[Data]))

ValtteriN_0-1641916346501.png

 

ValtteriN_1-1641916454407.png


I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

 

I get this 

mahsy_0-1641917770787.png

I would like to get 0 in empty cells. Thank for your help !

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors