Forum Discussion
Need Help to show values dynamically in column header in matrix
Hi Experts,
I have a below a report based on a direct query storage mode with year and month filter. I want to create it dynamic to show column header. if I select Jan month in filter, column header show the last 2-month for Nov and Dec including Jan to see the trends and when I select Feb, column header should show with Nov and Dec and so on
Below is the example screenshots. I have selected manually Jan, Nov and Dec in screenshot.
Expected output
5 Replies
- amitchandak
Super User
I am assuming you have a calendar table. Try
Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH)) Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max(Sales[Sales Date]),-3,MONTH))- sbm
Helper II
Hi amitchandak ,
Yes, I have a date table. The following formula returns the sales for the 3 months prior to the selected date. but I have not a requirement of previous 3-month sales. I have a measure of total sales. for now, I am selecting manually for Jan, Nov and Dec month to show total sales but I want to show dynamically if I select any single month from month filter, for example, Jan month then total sales should show also for Nov and Dec month with Jan as well in matrix visual. if I select Feb month then total sales should show Feb , Nov and Dec like this.
.
- amitchandak
Super User
That is what rolling should have done. You can also try this
Rolling 3 = varr _max = maxx('Date', 'Date'[Date]) var _min = minx('Date',dateadd('Date'[Date],-3,MONTH)) return CALCULATE(sum(Sales[Sales Amount]),filter(all(date), 'Date'[Date <=_max and 'Date'[Date >=_min)If it does not solve.
Can you share sample data and sample output. If possible please share a sample pbix file after removing sensitive information.Thanks.
Proud to be a Datanaut My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
- AnonymousNot applicable
Hi sbm ,
Check the topic below and see if it helps.
https://community.powerbi.com/t5/Desktop/How-to-hide-null-columns-in-matrix-table/m-p/562296#M265307.
Best Regards,
Jay
Community Support Team _ Jay Wang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.