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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Timo1980
Advocate I
Advocate I

Help on showing previous quarter value based on slicer selector without data table

Hi All,

 

below a simplified table as source. In need to make a barchart where the slicers would be one for year and one for quarter.

Now based on the quarter slicer, the barchart should show the previous month(s) and value. So if we are in Q2 then X-axis should show Q1 and Q2 savings. And when i select Q3, it would show then the values of Q1-2-3 etc. Now the source data does not have date tables, the years and quarters are whole numbers. What is the best solution to sort this?

 

Sales        OrgYear    Quarter   Saving

A202012
A202023
A202036
A202048
A202111
A202125
A202137
A202148

 

1 ACCEPTED SOLUTION

First create a disconnected quarter table as a slicer.

qtr_slicer = DISTINCT('Table'[QTR])

Then create a measure like below:

Measure = 
var selected_qtr = MAX(qtr_slicer[QTR])
return CALCULATE(SUM('Table'[Saving]),FILTER('Table','Table'[QTR]<=selected_qtr))

Vlianlmsft_0-1631864626869.png

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Timo1980 , You need to create a combined key

Year Qtr = [Year]*100 +[Qtr]

 

Create a new table with Qtr, Year and Year Qtr and do not join this Qtr with your table

 

Create a measure like

Meausre =

var _year = maxx(allselected(QTR), QTR[Year])

return

calculate(Sum(Table[saving]), filter(Table, Table[Year] =_year))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

hi amit, im getting a syntax error "The syntax for 'Table' is incorrect. (DAX(var _year = maxx(allselected(QTR), QTR[Year ])returncalculate(Sum('Table'[Saving]), filter(Table, 'Table'[Year ] =_year))))."

In the syntax error descr. it adds 2 more brackets and . for some reason

I have named the second table QTR.  And on the meaure above, is filtering on the year? because the main filter would be quarter.  seems im not allowed to upload the pbix file. Below screen is showing what i see when i filter on Q3. And i would like to also see Q1 and Q2 in the graph when i select Q3.

 

Timo1980_0-1631627016682.png

 

First create a disconnected quarter table as a slicer.

qtr_slicer = DISTINCT('Table'[QTR])

Then create a measure like below:

Measure = 
var selected_qtr = MAX(qtr_slicer[QTR])
return CALCULATE(SUM('Table'[Saving]),FILTER('Table','Table'[QTR]<=selected_qtr))

Vlianlmsft_0-1631864626869.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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