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
robertosljunior
Frequent Visitor

Calculate Month over Month with Month filter

I'd like to know if it's possible to filter a month and preserve the values in a chart.

 

I have the following sales data:

 

001.png

 

002.png

 

When I click on the month filter, I would like it to be displayed month by month until the selected month and the rest of the months appear blank.

 

003.png

 

Would it be possible to make this chart ?

 

Thanks a lot.

 

 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey,

 

this Power BI report contains a report page "Date Axis unrelated", that demonstrates how a slicer can be used to limit the value used on an axis.

 

Basically it's not the default, slicing (selecting) means filtering - that's the magic of Power BI.

 

To change this behavior, I use an anrelated dimension, in this example it's either related to fact tables nor to calendar table.

 

The simple thing

2017-07-22_15-21-45.png

 

Be aware that I'm using a column from the unrelated table.

 

Now it's necessary to "map" the data to the colums from the unrelated table, this mapping is necessary for each measure that you want to use with the unrelated column.

For this example this is done by this measure:

 

show MonthValues Unrelated = 
var maxDateSelection = MAXX(ALLSELECTED('Calendar'),MAX('Calendar'[MonthNoIndex]))
return

// lesser than means values are shown as column
IF(MAX('Calendar Unrelated'[MonthNoIndex]) <= maxDateSelection,
	//map the values to the columns of the
	//unrelated table
	CALCULATE(
		SUM('FactWithDates'[Amount]),
		//using the axis value from the unrelated table to map the facts to the 
		// unrelated table 
		//calendar unrelated -> calendar -> facts
		FILTER(All('Calendar'),
			'Calendar'[MonthNoIndex] = max('Calendar Unrelated'[MonthNoIndex]) &&
			'Calendar'[Year] = max('Calendar'[Year])
		)
	)
)

 

Hope this helps

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

5 REPLIES 5
TomMartens
Super User
Super User

Hey,

 

this Power BI report contains a report page "Date Axis unrelated", that demonstrates how a slicer can be used to limit the value used on an axis.

 

Basically it's not the default, slicing (selecting) means filtering - that's the magic of Power BI.

 

To change this behavior, I use an anrelated dimension, in this example it's either related to fact tables nor to calendar table.

 

The simple thing

2017-07-22_15-21-45.png

 

Be aware that I'm using a column from the unrelated table.

 

Now it's necessary to "map" the data to the colums from the unrelated table, this mapping is necessary for each measure that you want to use with the unrelated column.

For this example this is done by this measure:

 

show MonthValues Unrelated = 
var maxDateSelection = MAXX(ALLSELECTED('Calendar'),MAX('Calendar'[MonthNoIndex]))
return

// lesser than means values are shown as column
IF(MAX('Calendar Unrelated'[MonthNoIndex]) <= maxDateSelection,
	//map the values to the columns of the
	//unrelated table
	CALCULATE(
		SUM('FactWithDates'[Amount]),
		//using the axis value from the unrelated table to map the facts to the 
		// unrelated table 
		//calendar unrelated -> calendar -> facts
		FILTER(All('Calendar'),
			'Calendar'[MonthNoIndex] = max('Calendar Unrelated'[MonthNoIndex]) &&
			'Calendar'[Year] = max('Calendar'[Year])
		)
	)
)

 

Hope this helps

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens ,

 

Thanks for posting this data file. It's super helpful. I followed your guides but now am having another problem with column total is not displaying. I presented the data in a Matrix table and it shows nothing on the Column total Capture.PNG

Any ideas?

 

thanks

Hi @TomMartens, I do not know how to express my gratitute towards you for your help. I will never forget your help.

 

Thanks a lot for your help.

Anonymous
Not applicable

Hello @TomMartens 

 

thank you very much for this measure! It's helping me also a lot! Thanks!!

You're welcome! I'm glad I was able to help! 

It was a pleasure to think about your question and put it into my growing (hopefully) pbix file.



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

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.