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
Q007
Helper I
Helper I

How to combine Year and quarter columns in one column on a table?

Hi,

I have a table with 4 columns (Variable, year, quarter and value).  I want to combine the year and quarter columns in one column.

Please find below the table.

Thanks for your time in advance

Q007

 

Variable Year Quarter Value

 

VariableYearQuarterValue
FWA2010Q153627056
FWA2010Q258081119
FWA2010Q363781289
FWA2010Q470041487
FWA2011Q178019812
FWA2011Q285717968
FWA2011Q392185934
FWA2011Q499275469
FWA2012Q1108896889
FWA2012Q2118959095
FWA2012Q3127472408
FWA2012Q4136606883
FWA2013Q1148416477
FWA2013Q2160697670
FWA2013Q3171694528
FWA2013Q4182625385
FWA2014Q1194796221
FWA2014Q2206818234
FWA2014Q3219126737
FWA2014Q4231551080
FWA2015Q1245469495
FWA2015Q2260948600
FWA2015Q3278874269
FWA2015Q4298899900
FWA2016Q1327538953
FWA2016Q2356875850
FWA2016Q3392291621
FWA2016Q4427414578
FWA2017Q1475771846
FWA2017Q2524530295
FWA2017Q3579005581
FWA2017Q4633132713
FWA2018Q1728597556
FWA2018Q2826538209
FWA2018Q3934161410
FWA2018Q41042654201
FWA2019Q11108913292
FWA2019Q21219564570
FWA2019Q31262668593
FWA2019Q41306566235
1 ACCEPTED SOLUTION
AlexAlberga727
Resolver II
Resolver II

Year/Qtr = dDateTable[Year] & "-" & dDateTable[Quarter]

 

 

View solution in original post

13 REPLIES 13
theov
Advocate II
Advocate II

You can use combination of YEAR and QUARTER functions and joind them using CONCATENATE or "&" sign. Don't forget to join "Q" just before the quarter function also 😉 cause QUARTER only gives the number of quarter.

 

Here is a good video explaining it too:

https://www.youtube.com/watch?v=Oq5WOmo94_Q

m_g1983
New Member

I want to retrieve the previous quarter values by using this function
CALCULATE(SUM('Appended Tables'[Total BWS]), PREVIOUSQUARTER(FIRSTDATE('Appended Tables'[Date])))
 
Answer comes correct.
The problem is in visualization. I want to display through this key op2-2021-q2 but can't display the value as it is text and the input we need is date.
please help in this.
AlexAlberga727
Resolver II
Resolver II

Year/Qtr = dDateTable[Year] & "-" & dDateTable[Quarter]

 

 

Hi again,

a follow-up question. I am trying to change the "Type" of Year/Qtr from Text to Date but it won't work. Any idea? 

Year/Qtr = dDateTable[Year] & "-" & dDateTable[Quarter]

 

This wont work because the FX provided is concatenating values containing text. You may want to utilze your actual date field when creating the visualization you're wanting. Then also include the Year/Qtr values as either a filter, or simply additional information - to indicate when it happened. 

 

If you're passing a text value through a function that requires a date - you will have to obviously correct that. The FX we created should be a relationship to your date field. So any date provided will have a relational year/qtr info and the same goes for the new calculation you're putting together now. Hope that makes sence. Let me know if there is any more infomration you could provide to help me assist more.

 

Enjoy!

HI,

 

I am using PreviousQuarter Fx  to retrieve the previous Quarter values as below:

CALCULATE(SUM('Appended Tables'[Total BWS]), PREVIOUSQUARTER(FIRSTDATE('Appended Tables'[Date])))

 

The problem is that it needs date.

i want to pass as text.

i want some other function wherein i coulld fetch the previous quarter values without using previousquarter fx?
please help

Beacuse these values were concatenated they're considered TEXT. To mark a field as "Date" the values must be consistant with a date format (ex. 01/01/2020, 01-01-2020, 20/1/20). This field will not be able to be moved to a DATE type.

 

My suggestion is - retain date information within the table, and insert a slicer with the Year/Qtr values. This way you, or your users, will be able to quickly filter the data by that criteria.

Thanks for explanation and solution!

Is it doable to convert the "Quarter" column to date format? the conversion of the year column was straight forward.

If yes, would I be able to achieve what I originally (combining Quarter and Year columns to make a new "Year/Qtr" column in date format) wanted?

My understanding of DAX is very limited.

A text value cannot be formatted as a date.

 

However, in what ever table you're looking at im sure contains a date. You have calculated the Year/QTR for each record, which already contains date information.

 

Because you have now created a Year/QTR field - this field has essentially categorized your data (and dates), by year and quarter. You can now filter/sort by this field if needed opposed to the date field.

 

Tell me what your ultimate goal is for this field being formatted as a date and I'll point you in a better direction.

Hi,

My ultimate goal is to be able to have a slicer for time/date on my reports which are made of a set of variables tables. I have a time intelligence table, and I'd like to be able to connect it to the date (Year, QRT) column of our tables. As you know, currently I have two columns in ant given table, one column for year and another column for quarters.

 

Best

Q

 

Example1.png

Thanks a lot,

It was exactly what I wanted

Anonymous
Not applicable

is it ok for u ?

scr.png

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.

Top Solution Authors