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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
ErickReiis
Helper I
Helper I

Filter Buttons

Hello everyone, everything good?

I need help performing a calculation that is not working.

I want to create a treemap that will show me the change in units sold compared to the previous month

I have the following DAX measurement for this variation calculation:

Divide( Units sold Current Month - Units sold Previous month;

previous month units)

And with that I have the variation of several points that sell this product.

The question I wanted to ask is the following:

I need to create buttons where, when clicking, the user can select a range of variations.

For example: By clicking on the 10% variation button, all points that vary between 5% and 10% will be displayed on the Treemap.


5% button would show the points of sale that ranged from 1% to 5% And so on.

 

I tried to use calculate to make these filters but it doesn't work.

 

Can you shed some light on how to achieve this goal?

Here is an example print:

 

I tried the following measure to extract the specific variation percentage from the treemap, but it doesn't work

 

Variation 25 % = CALCULATE( [Variation];
[Variation] > 0.10 && [Variation] <= 0.25)

2 REPLIES 2
amitchandak
Super User
Super User

@ErickReiis , what is your previous month's formula?

 

Example formula for current and last month

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
last month Sales = CALCULATE(SUM(Sales[Sales Amount]),previousmonth('Date'[Date]))

 

MTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

LMTD =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = date(Year(_max1), month(_max1)-1, day(_max))
var _min = eomonth(_max1,-2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

Last Month =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _max = eomonth(_max1,-1)
var _min = eomonth(_max1,-2)+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

 

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak , I'm using the following dax measure :

Calculate( [Units Sold]; previousmonth(lastdate([Calendar].[Data])

 

And i have a measure about the units sold on the current month.

 

Calculate(Units Sold; DATESMTD(LastDate(Data))

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.