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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
AlmantasPBIguy
Frequent Visitor

Current and previous quarter from selected month

Hey guys,

we are trying to create a filter that would filter out the right quarter depending on the month selected.

For this we want to create a calculated column "CurrentQT" in the date table and use "Month & Year" to filter the specific month.

I. e. if you select Jul 2022 in the slicer, in the date table the column CurrentQT all the lines from the PREVIOUS quarted should be market 1.

If you select Aug 2022, in the date table the column Current qt all the lines from the CURRENT quarted should be market 1.

Currently we are using this measure:

CurrQT =

VAR _mo = MONTH(CALCULATE(LASTDATE(Dates[Date]), Dates[Month & Year] = SELECTEDVALUE(Dates[Month & Year])))
VAR _qt = QUARTER(CALCULATE(LASTDATE(Dates[Date]), Dates[Month & Year] = SELECTEDVALUE(Dates[Month & Year])))
VAR yearSel = YEAR(CALCULATE(LASTDATE(Dates[Date]), Dates[Month & Year] = SELECTEDVALUE(Dates[Month & Year]))

VAR currentQT = SELECTEDVALUE(Dates[Year])=yearSel&&SELECTEDVALUE(Dates[QuarterOfYear])=_qt
VAR lastQT = SELECTEDVALUE(Dates[Year])=yearSel&&SELECTEDVALUE(Dates[QuarterOfYear])=_qt-1

return
SWITCH( _mo
1, IF(lastQT, 1,0),
2, IF(currentQT, 1,0),
3, IF(currentQT, 1,0),
4, IF(lastQT, 1,0),
5, IF(currentQT, 1,0),
6, IF(currentQT, 1,0),
7, IF(lastQT, 1,0),
8, IF(currentQT, 1,0),
9, IF(currentQT, 1,0),
10, IF(lastQT, 1,0),
11, IF(currentQT, 1,0),
12, IF(currentQT, 1,0))

Then the plan is to create a column based on this measure CurrentQT = [CurrQT]

What are we doing wrong? Maybe you would approarch this in another dirrection? 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

I. e. if you select Jul 2022 in the slicer, in the date table the column CurrentQT all the lines from the PREVIOUS quarted should be market 1.

If you select Aug 2022, in the date table the column Current qt all the lines from the CURRENT quarted should be market 1.

 

A measure cannot influence a column.  That means a user choice cannot be written back into a table dynamically.  You need to use measures all the way. 

 

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

I. e. if you select Jul 2022 in the slicer, in the date table the column CurrentQT all the lines from the PREVIOUS quarted should be market 1.

If you select Aug 2022, in the date table the column Current qt all the lines from the CURRENT quarted should be market 1.

 

A measure cannot influence a column.  That means a user choice cannot be written back into a table dynamically.  You need to use measures all the way. 

 

Please provide sanitized sample data that fully covers your issue. I can only help you with meaningful sample data.
Please paste the data into a table in your post or use one of the file services like OneDrive or Google Drive. Screenshots of your source data are not useful.
Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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