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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Filter values x-axis dynamically

Hi! I created a monthly percent difference chart using Power BI's quick measure, month-over-month change. My problem is the value for the next month (-100%) always appear in the chart. I only want up until the current month (in this case/example, February).

 pbi.JPG

When I change the filter (visual level) of the x-axis such that all months are selected except for March, I get my desired chart.pbi2.JPG pbi3.JPG

 

My question now is, is there a way to dynamically choose the months (in x-axis) here? I'm not talking about filtering the data used under the chart but just the values/ categories in the axis. Note that the axis I'm using is a date hierarchy - with year and level.

 

If there's no way to dynamically filter the x-axis, can you suggest another way of making this kind of chart to achieve my desired result?

 

Thanks!

 

girinpanda

1 ACCEPTED SOLUTION

@Anonymous

 

I Answer in PM. The answer to avoid this is:

 

Cost MoM% = 
IF(MAX('Table1'[Date_new])<>BLANK();
IF(
	ISFILTERED('Table1'[Date_new]);
	ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column.");
	VAR __PREV_MONTH =
		CALCULATE(
			SUM('Table1'[Cost]);
			DATEADD('Table1'[Date_new].[Date]; -1; MONTH)
		)
	RETURN
		DIVIDE(SUM('Table1'[Cost]) - __PREV_MONTH; __PREV_MONTH)
))

 




Lima - Peru

View solution in original post

10 REPLIES 10
Vvelarde
Community Champion
Community Champion

@Anonymous

 

Hi add in the quick measure in the begin:

 

IF (HASONEVALUE(Table1[Date]);

 

Regards

Victor

Lima Peru




Lima - Peru
Anonymous
Not applicable

Hi @Vvelarde,

 

How do I add that here? Do I remove ISFILTERED?

 

ExtendedCost MoM% =
IF( ISFILTERED('Table'[Date]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __PREV_MONTH =
CALCULATE(
SUM(''Table'[Cost]),
DATEADD(''Table'[Date].[Date], -1, MONTH)
)
RETURN
DIVIDE(SUM(''Table'[Cost]) - __PREV_MONTH, __PREV_MONTH)
)

@Anonymous

 

Before of ISfiltered

 

IF(HASONEVALUE(.........);

IF (ISFILTERED(.....




Lima - Peru
Anonymous
Not applicable

Hi @Vvelarde,

 

It says Capture.JPG

 

chart.png




Lima - Peru
Anonymous
Not applicable

@Vvelarde

 

Still says ; is invalid to me. What's the difference of using a ' ; ' and a ' , ' ?

 

Can you also explain what does adding IF(HASONEVALUE()) does to the formula?

 

Thanks so much! : )

@Anonymous

 

The ; and , is just regional settings.

 

If you Formula works with , all should be with ,

 

HASONEVALUE evaluate in your scenario if you had a date in that context.  In April you don't have dates so the result is blank and don't show in the visual.

 

Regards

 




Lima - Peru
Anonymous
Not applicable

@Vvelarde

 

Okay, I understand that part now. Thanks Victor! But the thing is the month on month change quick measure always gives the final row (the -100%).  What should I do so that the last row will not end up showing in my chart? (Thanks for answering my endless questions 🙂 )

 Capture.JPG

@Anonymous

 

I Answer in PM. The answer to avoid this is:

 

Cost MoM% = 
IF(MAX('Table1'[Date_new])<>BLANK();
IF(
	ISFILTERED('Table1'[Date_new]);
	ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column.");
	VAR __PREV_MONTH =
		CALCULATE(
			SUM('Table1'[Cost]);
			DATEADD('Table1'[Date_new].[Date]; -1; MONTH)
		)
	RETURN
		DIVIDE(SUM('Table1'[Cost]) - __PREV_MONTH; __PREV_MONTH)
))

 




Lima - Peru
Anonymous
Not applicable

@Vvelarde

 

Thanks you so much! 🙂

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.