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

SUMMARIZECOLUMNS returns blank values

I have a PowerBI dataset with 4 tables. Table 1 contains agent/company information; Table 2 contains product information; Table 3 contains value information, table 4 contains dates information. There are relationships between four tables. However, they are all direct queries. The details cannot be shown in the table view and I cannot access to power query for those four tables neither. I am trying to create a calculated table to pull all the data points that I care into one. I use the below DAX to create the table. However, I notice that it returns many rows with blank or 0 values. I am wondering if there is a way I can modify the DAX to have it return only the value is non blank or greater than 0.

 

NewTable =  
VAR x = YEAR(TODAY())*100 + MONTH(TODAY()) – 1
//get the month id as the most recent one
VAR y = FILTER(‘TABLE 1’, LEFT(‘TABLE 1’[ID], 1) = “A”)
//get the agent id starts with A
VAR z = FILTER(‘TABLE 1’, ‘TABLE 1’[COMPANY NAME] <> “-”)
//get the company name is not “-“
VAR n = FILTER(‘TABLE 2’, ‘TABLE 2’[PRODUCT TYPE] = “ABC” || ‘TABLE 2’[PRODUCT TYPE] = “BCD”)
//get only the product type is “ABC” or “BCD”
RETURN
SUMMARIZECOLUMNS(‘TABLE 1’[ID], ‘TABLE 1’[COMPANY NAME], ‘TABLE 2’[PRODUCT TYPE], y, z, n, “MAXMONTH”, x, “VALUE”, CALCULATE(SUM(‘TABLE 3’[VALUES]), FILTER(‘TABLE 4’[MONTH ID] = x)))

What the DAX returns

raymondchen_0-1699298561989.png

What I hope it will return

raymondchen_1-1699298750546.png

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

First thing I'd try would be IGNORE around the x column.

 

NewTable =
VAR x = YEAR ( TODAY () ) * 100 + MONTH ( TODAY () ) - 1
VAR y = FILTER ( 'TABLE 1', LEFT ( 'TABLE 1'[ID], 1 ) = "A" )
VAR z = FILTER ( 'TABLE 1', 'TABLE 1'[COMPANY NAME] <> "-" )
VAR n =
    FILTER (
        'TABLE 2',
        'TABLE 2'[PRODUCT TYPE] = "ABC"
            || 'TABLE 2'[PRODUCT TYPE] = "BCD"
    )
RETURN
    SUMMARIZECOLUMNS (
        'TABLE 1'[ID],
        'TABLE 1'[COMPANY NAME],
        'TABLE 2'[PRODUCT TYPE],
        y,
        z,
        n,
        "MAXMONTH", IGNORE ( x ),
        "VALUE",
            CALCULATE (
                SUM ( 'TABLE 3'[VALUES] ),
                FILTER ( 'TABLE 4', 'TABLE 4'[MONTH ID] = x )
            )
    )

 

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

First thing I'd try would be IGNORE around the x column.

 

NewTable =
VAR x = YEAR ( TODAY () ) * 100 + MONTH ( TODAY () ) - 1
VAR y = FILTER ( 'TABLE 1', LEFT ( 'TABLE 1'[ID], 1 ) = "A" )
VAR z = FILTER ( 'TABLE 1', 'TABLE 1'[COMPANY NAME] <> "-" )
VAR n =
    FILTER (
        'TABLE 2',
        'TABLE 2'[PRODUCT TYPE] = "ABC"
            || 'TABLE 2'[PRODUCT TYPE] = "BCD"
    )
RETURN
    SUMMARIZECOLUMNS (
        'TABLE 1'[ID],
        'TABLE 1'[COMPANY NAME],
        'TABLE 2'[PRODUCT TYPE],
        y,
        z,
        n,
        "MAXMONTH", IGNORE ( x ),
        "VALUE",
            CALCULATE (
                SUM ( 'TABLE 3'[VALUES] ),
                FILTER ( 'TABLE 4', 'TABLE 4'[MONTH ID] = x )
            )
    )

 

It works. Amazing! Thank you very much.

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.