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
troyhimes
Resolver I
Resolver I

ADDCOLUMNS with a FILTER?

I would like to add a date filter to the ADDCOLUMNS function below, but I can't seem to get it right.  What structure do I use?

 

FILTER('Development Roll-up','Development Roll-up'[Date]< Date(2021,1,1))

 

EVALUATE
ADDCOLUMNS (
    SUMMARIZECOLUMNS( 
    'Development Roll-up'[Date],
    'Development Roll-up'[Area],
    'Development Roll-up'[Heading],
    'Development Roll-up'[Plan],
    'Development Roll-up'[Cost Code],
    'Development Roll-up'[Mining Desc],
    'Development Roll-up'[Development Tons]),
    "Ft. Advance", [Sum of Ft. Advance],
    "11'x12' eq ft", [Sum of Eq ft 11'x12'],
    "13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
)
2 ACCEPTED SOLUTIONS

HI @troyhimes ,

 

Instead of Summarize Column, you can just try summarize.

Let me know if that works

 

==
ADDCOLUMNS (
SUMMARIZE (
FILTER (
'Development Roll-up',
'Development Roll-up'[Date]
< DATE ( 2021, 1, 1 )
),
'Development Roll-up'[Date],
'Development Roll-up'[Area],
'Development Roll-up'[Heading],
'Development Roll-up'[Plan],
'Development Roll-up'[Cost Code],
'Development Roll-up'[Mining Desc],
'Development Roll-up'[Development Tons]
),
"Ft. Advance", [Sum of Ft. Advance],
"11'x12' eq ft", [Sum of Eq ft 11'x12'],
"13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
)

 

 

Regards,

HN

 

 

View solution in original post

Anonymous
Not applicable

EVALUATE
CALCULATETABLE(

	ADDCOLUMNS (
	    SUMMARIZE(
		    'Development Roll-up',
		    'Development Roll-up'[Date],
		    'Development Roll-up'[Area],
		    'Development Roll-up'[Heading],
		    'Development Roll-up'[Plan],
		    'Development Roll-up'[Cost Code],
		    'Development Roll-up'[Mining Desc],
		    'Development Roll-up'[Development Tons]
	  	),
	    "Ft. Advance", [Sum of Ft. Advance],
	    "11'x12' eq ft", [Sum of Eq ft 11'x12'],
	    "13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
	),
	
	'Development Roll-up'[Date] < Date(2021, 1, 1)
)

Do the above and you're good to go. This is much easier to manipulate with filters than the solution based on SUMMARIZECOLUMNS.

 

Best

D

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

It's much easier than you think and what others would have you believe...

EVALUATE
CALCULATETABLE(

	ADDCOLUMNS (
	    SUMMARIZECOLUMNS (
	    'Development Roll-up'[Date],
	    'Development Roll-up'[Area],
	    'Development Roll-up'[Heading],
	    'Development Roll-up'[Plan],
	    'Development Roll-up'[Cost Code],
	    'Development Roll-up'[Mining Desc],
	    'Development Roll-up'[Development Tons] ),
	    "Ft. Advance", [Sum of Ft. Advance],
	    "11'x12' eq ft", [Sum of Eq ft 11'x12'],
	    "13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
	),
	
	FILTER(
		'Development Roll-up',
		'Development Roll-up'[Date] < Date(2021,1,1)
	)
)

 

Best

D

Greg_Deckler
Super User
Super User

I believe the syntax for SUMMARIZECOLUMNS is:

 

EVALUATE
ADDCOLUMNS (
    SUMMARIZECOLUMNS( 
    'Development Roll-up'[Date],
    'Development Roll-up'[Area],
    'Development Roll-up'[Heading],
    'Development Roll-up'[Plan],
    'Development Roll-up'[Cost Code],
    'Development Roll-up'[Mining Desc],
    'Development Roll-up'[Development Tons]),
    FILTER('Development Roll-up','Development Roll-up'[Date]< Date(2021,1,1)),
    "Ft. Advance", [Sum of Ft. Advance],
    "11'x12' eq ft", [Sum of Eq ft 11'x12'],
    "13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
)

 

Using SUMMARIZE would be:

EVALUATE
ADDCOLUMNS (
    SUMMARIZECOLUMNS( 
    FILTER('Development Roll-up','Development Roll-up'[Date]< Date(2021,1,1)),
    'Development Roll-up'[Date],
    'Development Roll-up'[Area],
    'Development Roll-up'[Heading],
    'Development Roll-up'[Plan],
    'Development Roll-up'[Cost Code],
    'Development Roll-up'[Mining Desc],
    'Development Roll-up'[Development Tons]),
    "Ft. Advance", [Sum of Ft. Advance],
    "11'x12' eq ft", [Sum of Eq ft 11'x12'],
    "13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

HI @troyhimes ,

 

Instead of Summarize Column, you can just try summarize.

Let me know if that works

 

==
ADDCOLUMNS (
SUMMARIZE (
FILTER (
'Development Roll-up',
'Development Roll-up'[Date]
< DATE ( 2021, 1, 1 )
),
'Development Roll-up'[Date],
'Development Roll-up'[Area],
'Development Roll-up'[Heading],
'Development Roll-up'[Plan],
'Development Roll-up'[Cost Code],
'Development Roll-up'[Mining Desc],
'Development Roll-up'[Development Tons]
),
"Ft. Advance", [Sum of Ft. Advance],
"11'x12' eq ft", [Sum of Eq ft 11'x12'],
"13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
)

 

 

Regards,

HN

 

 

@harshnathani  that did the trick, thanks!

 

@Anonymous I understood the logic of your method but got the following error: SummarizeColumns can not have outside filter context.  For future use of CALCULATETABLE command, do you know why I would get that error?

Anonymous
Not applicable

EVALUATE
CALCULATETABLE(

	ADDCOLUMNS (
	    SUMMARIZE(
		    'Development Roll-up',
		    'Development Roll-up'[Date],
		    'Development Roll-up'[Area],
		    'Development Roll-up'[Heading],
		    'Development Roll-up'[Plan],
		    'Development Roll-up'[Cost Code],
		    'Development Roll-up'[Mining Desc],
		    'Development Roll-up'[Development Tons]
	  	),
	    "Ft. Advance", [Sum of Ft. Advance],
	    "11'x12' eq ft", [Sum of Eq ft 11'x12'],
	    "13.5'x15' eq ft", [Sum of Eq ft 13.5'x15']
	),
	
	'Development Roll-up'[Date] < Date(2021, 1, 1)
)

Do the above and you're good to go. This is much easier to manipulate with filters than the solution based on SUMMARIZECOLUMNS.

 

Best

D

Hi Greg,

That's what I thought...but I had tried both of those methods and got the following errors.

 

For SUMMARIZECOLUMNS:  A single value for column 'Date' in table 'Development Roll-up' cannot be determined.

 

For ADDCOLUMNS:  Function ADDCOLUMNS expects a column name as argument number 2.

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