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 September 15. Request your voucher.

Reply
fcarvalho75
Frequent Visitor

How to use Summarizecolumns to filter by Year and Description + sum Total Revenue

Hi,

 

I'm brand new on PowerBi, I have 3 facts and I need to get the % of comparison to the previous year.

 

Basically, there are 4 fields:

 

1) Year

2) Month

3) Type

4) Revenue

 

I need to make a formula in order to get the % of year and % by month (same period).

 

I tried many things, but I am not able to solve it yet.

 

Any help, I really appreciate it.


Fernanda

1 ACCEPTED SOLUTION

@fcarvalho75

 

In DAX, you can add FILTER() in SUMMARIZACOLUMNS() function, Like:

 

Total =
SUMMARIZECOLUMNS (
    dm_calendar[skCalendar],
    dm_calendar[year],
    dm_calendar[month],
    ft_operational[typeDescription],
    FILTER ( dm_calendar, dm_calendar[year] = 2016 ),
    "Total Revenue per Year", SUM ( ft_operational[amount] ) / 1000
)

 

If you need to filter by Month, you need to filter on both Year and Month.

 

(RevenueCurrentMonth) =
VAR
dataref=[(dataref)]
return

CALCULATE([(Total Revenue)],

FILTER('dm_calendar',

'dm_calendar'[year] = year(dataref) &&

'dm_calendar'[month] = month(dataref)

)

)

 

Regards,

View solution in original post

5 REPLIES 5
Phil_Seamark
Microsoft Employee
Microsoft Employee

Can you please post a sample of your data.

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

I was able to create a new table using:

 

Total2017 = SUMMARIZECOLUMNS(dm_calendar[skCalendar];dm_calendar[year];dm_calendar[month];ft_operational[typeDescription];"Total Revenue per Year";sum(ft_operational[amount])/1000)

 

However I need to filter by year, for example: Year = 2016

 

Also, I tried to create a measure, that works, but I need to make the same by Month and I get error.

 

(RevenueCurrentYear) =
VAR
dataref=[(dataref)]
return

CALCULATE([(Total Revenue)];'dm_calendar'[year] = year(dataref))

 

Tks a lot

@fcarvalho75

 

In DAX, you can add FILTER() in SUMMARIZACOLUMNS() function, Like:

 

Total =
SUMMARIZECOLUMNS (
    dm_calendar[skCalendar],
    dm_calendar[year],
    dm_calendar[month],
    ft_operational[typeDescription],
    FILTER ( dm_calendar, dm_calendar[year] = 2016 ),
    "Total Revenue per Year", SUM ( ft_operational[amount] ) / 1000
)

 

If you need to filter by Month, you need to filter on both Year and Month.

 

(RevenueCurrentMonth) =
VAR
dataref=[(dataref)]
return

CALCULATE([(Total Revenue)],

FILTER('dm_calendar',

'dm_calendar'[year] = year(dataref) &&

'dm_calendar'[month] = month(dataref)

)

)

 

Regards,

Simon, thank you so much! This is exactly what I was looking for! Really appreciate it.

Hi there,

 

I recommend you add a column to your fact table that is using the DATE datatype, so perhaps add a calcuated column like this

 

So perhaps in the Query Editor or keep from  your source system have a column that you can add the following forumlas over:

 

There are a bunch of handy functions in DAX that allow you do to period comparisons but they need to work on a column that is a datetime rather than an integer.

 

Sum of Revenue LY = 
        CALCULATE(
                  SUM(Table1[Revenue]),
                  DATEADD('Table1'[myDateColumn],-12,MONTH)
		    	)

 

Percentage Change = DIVIDE([Sum of Revenue], ([Sum of Revenue]-[Sum of Revenue LY]))

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

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.