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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
JRHans09
Resolver II
Resolver II

Create new table with AddColumns and CrossJoin, but exclude rows with blank values

I am trying to create a budget table based on sales values from the previous year, but would like to exclude any rows that might have blank Annual Budget values for the current year because the particular combination of the joined rows might not have had sales in the previous year.

 

Is it possible to use ADDCOLUMNS and CROSSJOIN to create a new table, but excludes rows in that new table based on the results of the CALCULATE function?


See here:

 

 

 

Annual Budget = 
ADDCOLUMNS(
	FILTER(
		CROSSJOIN(
			DISTINCT( Dates[Month MMM] ),
			DISTINCT( Dates[Year] ),
			VALUES( SalesRep[Full Name] ),
			VALUES( JobType[JobType1] )
		),
		Dates[Year] = MAX( Dates[Year] ) //to always keep current year
	),
	"Annual Budget",
	CALCULATE(
		[Total Sales],
		DATEADD(
			Dates[Date],
			-1,
			YEAR
		)
	)
)

 

 

 

 

And see sample results:

Annual Budget

Full Name

Job Type1

Month MMM

Year

 

Tom

Local

Jan

2020

35,000

Dave

Local

Jan

2020

50,000

Sherry

Local

Jan

2020

 

Alice

Local

Jan

2020

45,000

Talia

Local

Jan

2020

 

If neither Tom nor Alice had sales for:

  1. Local
  2. Jan
  3. 2019 (table above shows 2020, but budget should pull data from 2019)

Is it possible to exclude those rows in the new table?

 

Thanks in advance.

3 ACCEPTED SOLUTIONS
d_gosbell
Super User
Super User

This should be possible, in theory you should be able to wrap your existing expression in FILTER()

 

eg.

Annual Budget = 
FILTER(
ADDCOLUMNS(
	FILTER(
		CROSSJOIN(
			DISTINCT( Dates[Month MMM] ),
			DISTINCT( Dates[Year] ),
			VALUES( SalesRep[Full Name] ),
			VALUES( JobType[JobType1] )
		),
		Dates[Year] = MAX( Dates[Year] ) //to always keep current year
	),
	"Annual Budget",
	CALCULATE(
		[Total Sales],
		DATEADD(
			Dates[Date],
			-1,
			YEAR
		)
	)
),
NOT( ISBLANK( [Annual Budget] ) )
)

 

 

View solution in original post

v-lili6-msft
Community Support
Community Support

hi  @JRHans09 

You could add a FILTER in the for mula as below:

Annual Budget =
FILTER(ADDCOLUMNS(
    FILTER(
        CROSSJOIN(
            DISTINCT( Dates[Month MMM] ),
            DISTINCT( Dates[Year] ),
            VALUES( SalesRep[Full Name] ),
            VALUES( JobType[JobType1] )
        ),
        Dates[Year] = MAX( Dates[Year] ) //to always keep current year
    ),
    "Annual Budget",
    CALCULATE(
        [Total Sales],
        DATEADD(
            Dates[Date],
            -1,
            YEAR
        )
    )
,[Annual Budget]<>BLANK())

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post


@JRHans09 wrote:

@d_gosbell - thanks, your answer is virtually the same.


But they are not exactly the same. I am using NOT( ISBLANK( ... ) ) as it will ONLY exclude blanks. if you do <> BLANK() it will exclude blanks and 0 values (since blanks coalesce to a numeric value of 0 when you compare them to a numeric measure or column)

View solution in original post

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi  @JRHans09 

You could add a FILTER in the for mula as below:

Annual Budget =
FILTER(ADDCOLUMNS(
    FILTER(
        CROSSJOIN(
            DISTINCT( Dates[Month MMM] ),
            DISTINCT( Dates[Year] ),
            VALUES( SalesRep[Full Name] ),
            VALUES( JobType[JobType1] )
        ),
        Dates[Year] = MAX( Dates[Year] ) //to always keep current year
    ),
    "Annual Budget",
    CALCULATE(
        [Total Sales],
        DATEADD(
            Dates[Date],
            -1,
            YEAR
        )
    )
,[Annual Budget]<>BLANK())

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
d_gosbell
Super User
Super User

This should be possible, in theory you should be able to wrap your existing expression in FILTER()

 

eg.

Annual Budget = 
FILTER(
ADDCOLUMNS(
	FILTER(
		CROSSJOIN(
			DISTINCT( Dates[Month MMM] ),
			DISTINCT( Dates[Year] ),
			VALUES( SalesRep[Full Name] ),
			VALUES( JobType[JobType1] )
		),
		Dates[Year] = MAX( Dates[Year] ) //to always keep current year
	),
	"Annual Budget",
	CALCULATE(
		[Total Sales],
		DATEADD(
			Dates[Date],
			-1,
			YEAR
		)
	)
),
NOT( ISBLANK( [Annual Budget] ) )
)

 

 

@d_gosbell - thanks, your answer is virtually the same.


@JRHans09 wrote:

@d_gosbell - thanks, your answer is virtually the same.


But they are not exactly the same. I am using NOT( ISBLANK( ... ) ) as it will ONLY exclude blanks. if you do <> BLANK() it will exclude blanks and 0 values (since blanks coalesce to a numeric value of 0 when you compare them to a numeric measure or column)

@d_gosbell - thank you for your clarification. It is helpful. I will apply the logic to my case.

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.