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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
js2246
Frequent Visitor

Aggregation and dynamic filter

I am new to Power BI, having worked primarily with Tableau in the past. I am bringing in a couple data sets that I need to be able to merge on a summary level but I want to be able to maintain the filtering on the individual level. Does anyone know how I can do this?

 

I have two simplified example data sets that show individual Clients in 2016 and 2017, the products they purchased on a given date and the number of visits before purchase.

 

2016    
Product AProduct BDate2016 Clients2016 Visits
Ab1/1/201612
Ac4/16/201611
Bb3/10/201613
Bb2/12/201614
Ba8/9/201611
Ac6/6/201612
Bc1/14/201615

 

 

2017    
Product AProduct BDate2017 Clients2017 Visits
Ac4/3/201713
Ab3/8/201714
Ab9/16/201715
Bb1/5/201714
Ba8/7/201717
Ac4/11/201718
Bc10/30/201712

 

Granted we would have many more observations then this. I need the data to be originally on the individual level because I want the eventual user of the dashboard to be able to change what date ranges they want to look at. So I want a filter on the final output that can be interfaced with. However, I want the final results shown to be grouped by Product A, and Product B, with Clients and Visits to be summations. Then I have to be able to join the aggregated 2016 and 2017 tables on Product A and Product B so that I can do calculations across the years such as growth.

 

Product AProduct B2016 Clients2017 Clients16-17 Client Growth2016 Visits2017 Visits16-17 Visit Growth
Ab12100%29350%
Ac220%311267%
Ba110%17600%
Bb21-50%74-43%
Bc110%52-60%

 

Is this possible in Power Bi?

1 ACCEPTED SOLUTION
nickchobotar
Skilled Sharer
Skilled Sharer

Hello@js2246

 

So, @CahabaData  pretty much laid out the whole strategy for you. I went ahead and put the pbix together for you and since you are new to Power BI jumping into Power Query along with DAX might be a little overwhelming, so I created the solution only in DAX. (As Lincoln said one war at a time) . I just simply used UNION() function to append your 2016 and 2017 tables and then used some simple DAX CALCULATE()s to apply correct filters to your metrics.

 

Here is the download link:


https://1drv.ms/u/s!AsgNvkRwqGC7gwZj-6GQoXmWYFRW


Table = UNION( '2016', '2017' )

Clients 2016 = 
CALCULATE(
	SUM('Table'[ Clients]),
	YEAR('Table'[Date]) = 2016
)

Clients 2017 = 
CALCULATE(
	SUM('Table'[ Clients]),
	YEAR('Table'[Date]) = 2017
)

16-17 Client Growth = DIVIDE( [Clients 2017], [Clients 2016] ) -1

Visits 2016 = 
CALCULATE(
	SUM('Table'[ Visits]),
	YEAR('Table'[Date]) = 2016
)


Visits 2017 = 
CALCULATE(
	SUM('Table'[ Visits]),
	YEAR('Table'[Date]) = 2017
)

16-17 Visit Growth = DIVIDE([Visits 2017], [Visits 2016], 0) -1

image.png

 

image.png

 

View solution in original post

2 REPLIES 2
nickchobotar
Skilled Sharer
Skilled Sharer

Hello@js2246

 

So, @CahabaData  pretty much laid out the whole strategy for you. I went ahead and put the pbix together for you and since you are new to Power BI jumping into Power Query along with DAX might be a little overwhelming, so I created the solution only in DAX. (As Lincoln said one war at a time) . I just simply used UNION() function to append your 2016 and 2017 tables and then used some simple DAX CALCULATE()s to apply correct filters to your metrics.

 

Here is the download link:


https://1drv.ms/u/s!AsgNvkRwqGC7gwZj-6GQoXmWYFRW


Table = UNION( '2016', '2017' )

Clients 2016 = 
CALCULATE(
	SUM('Table'[ Clients]),
	YEAR('Table'[Date]) = 2016
)

Clients 2017 = 
CALCULATE(
	SUM('Table'[ Clients]),
	YEAR('Table'[Date]) = 2017
)

16-17 Client Growth = DIVIDE( [Clients 2017], [Clients 2016] ) -1

Visits 2016 = 
CALCULATE(
	SUM('Table'[ Visits]),
	YEAR('Table'[Date]) = 2016
)


Visits 2017 = 
CALCULATE(
	SUM('Table'[ Visits]),
	YEAR('Table'[Date]) = 2017
)

16-17 Visit Growth = DIVIDE([Visits 2017], [Visits 2016], 0) -1

image.png

 

image.png

 

CahabaData
Memorable Member
Memorable Member

Yes PBI can do this.  I would say most of us developers would not create a static display that is only good for the 2016-2017 period - but instead build a report/visual that is ongoing with rolling data so that it would be 'Current Year' and 'Last Year'.

 

My approach would be to append the year tables into 1, and in ongoing years to continue to do that.  Add a date table.

 

Your client count or visit count by product row (current year, last year) will be dax measures.

www.CahabaData.com

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.