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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
FatBlackCat30
Microsoft Employee
Microsoft Employee

Return text value based off condition

Hi all,

 

I am trying to create a DAX mesure that will return the current quarter. my data looks like this:

 

Ive tried a bunch of different ways but nothing is working. the Dax would return the QTR of the latest date. so since the latested date is this data set is 11/25/20 the result should be Q2. what is the best approach to accomplish this? 

 

thank you!!

 

dateQTRUsers
10/30/2020Q1105
10/31/2020Q1515
11/1/2020Q25415
11/2/2020Q2545
11/3/2020Q25645
11/4/2020Q25454
11/5/2020Q2545
11/6/2020Q26458
11/7/2020Q23908
11/8/2020Q23661
11/9/2020Q23414
11/10/2020Q23167
11/11/2020Q22920
11/12/2020Q22673
11/13/2020Q22426
11/14/2020Q22179
11/15/2020Q21932
11/16/2020Q21685
11/17/2020Q21438
11/18/2020Q21191
11/19/2020Q2944
11/20/2020Q2697
11/21/2020Q2450
11/22/2020Q2203
11/23/2020Q21548
11/24/2020Q2125
11/25/2020Q212588

 

2 ACCEPTED SOLUTIONS
Nathaniel_C
Community Champion
Community Champion

Hi @FatBlackCat30 ,

 

Try this measure,

 

Latest QTR = 


CALCULATE(MAX('Table'[QTR]),Filter(all('Table'),'Table'[date]=MAX('Table'[date])))

 

q2.PNG
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

amitchandak
Super User
Super User

@FatBlackCat30 , if you want to select a date(slicer) datesqtd can help. If you do want to select then stop your date calendar on today.

 

With date calendar and date in slicer

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))

Last complete QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-1,QUARTER))))
Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))

 

Else you need qtr start date in the calendar

Try like

 

Measure =
var _min = minx(allselected('Date') , 'Date'[Qtr Start Date]) //refer to blog to get this
var _min = maxx(allselected('Date') , 'Date'[Date])
return
calculate(countrows('Table'), Filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max ))


Measure =
var _min = minx(allselected('Date') , 'Date'[Qtr Start Date]) //refer to blog to get this
var _min = maxx(allselected('Date') , 'Date'[Date])
return
calculate(countrows('Table'), Filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max ))

 

For Qtr Start Date

Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calend...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
FatBlackCat30
Microsoft Employee
Microsoft Employee

thank you @Nathaniel_C  & @amitchandak  both exellent solutions. I almost had it working, I just missed a small part

amitchandak
Super User
Super User

@FatBlackCat30 , if you want to select a date(slicer) datesqtd can help. If you do want to select then stop your date calendar on today.

 

With date calendar and date in slicer

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date])))
Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-1,QUARTER)))

Last complete QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD( ENDOFQUARTER(dateadd('Date'[Date],-1,QUARTER))))
Last to last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date],-2,QUARTER)))

 

Else you need qtr start date in the calendar

Try like

 

Measure =
var _min = minx(allselected('Date') , 'Date'[Qtr Start Date]) //refer to blog to get this
var _min = maxx(allselected('Date') , 'Date'[Date])
return
calculate(countrows('Table'), Filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max ))


Measure =
var _min = minx(allselected('Date') , 'Date'[Qtr Start Date]) //refer to blog to get this
var _min = maxx(allselected('Date') , 'Date'[Date])
return
calculate(countrows('Table'), Filter('Table', 'Table'[Date] >=_min && 'Table'[Date] <=_max ))

 

For Qtr Start Date

Creating Financial Calendar - From Any Month
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calend...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Nathaniel_C
Community Champion
Community Champion

Hi @FatBlackCat30 ,

 

Try this measure,

 

Latest QTR = 


CALCULATE(MAX('Table'[QTR]),Filter(all('Table'),'Table'[date]=MAX('Table'[date])))

 

q2.PNG
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.