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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Dee
Helper III
Helper III

Excel columns with double date range headings

Hi all,

 

I am trying to import data from excel which happens to have double headings. One is the date range in quarter, and the other is the quarter range as shown below.


How do I make it such that I transpose the columns, and still maintain the right headings In date format?

 

    2017/18 Q12017/18 Q22017/18 Q32017/18 Q42019/20 Q12019/20 Q22019/20 Q32019/20 Q42019/20 Q12019/20 Q22019/20 Q32019/20 Q42020/21 Q12020/21 Q22020/21 Q32020/21 Q4
ABCDJul'17- Sep'17Oct'17- Dec'17Jan'18 - Mar'18Apr'18- Jun'18Jul'18- Sep'18Oct'18- Dec'18Jan'19 - Mar'19Apr'19- Jun'19Jul'19- Sep'19Oct'19- Dec'19Jan'20 - Mar'20Apr'20- Jun'20Jul'20- Sep'20Oct'20- Dec'20Jan'21 - Mar'21Apr'21- Jun'21

 

I would really appreciate any help in solving this.

 

TIA

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Dee,

 

Create 2 calculated columns as below:

year & quarter = YEAR('Table'[Date])&"Q"&QUARTER('Table'[Date])
Month Year = 
VAR minmonth=CALCULATE(MIN('Table'[Date]),FILTER(ALL('Table'),'Table'[year & quarter]=EARLIER('Table'[year & quarter])))
VAR maxmonth=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[year & quarter]=EARLIER('Table'[year & quarter])))
Return
FORMAT(minmonth,"MMM")&"'"&FORMAT(minmonth,"YY")&"-"&FORMAT(maxmonth,"MMM")&"'"&FORMAT(maxmonth,"YY")

Create a matirx and you will see:

v-kelly-msft_0-1614845842768.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @Dee,

 

Create 2 calculated columns as below:

year & quarter = YEAR('Table'[Date])&"Q"&QUARTER('Table'[Date])
Month Year = 
VAR minmonth=CALCULATE(MIN('Table'[Date]),FILTER(ALL('Table'),'Table'[year & quarter]=EARLIER('Table'[year & quarter])))
VAR maxmonth=CALCULATE(MAX('Table'[Date]),FILTER(ALL('Table'),'Table'[year & quarter]=EARLIER('Table'[year & quarter])))
Return
FORMAT(minmonth,"MMM")&"'"&FORMAT(minmonth,"YY")&"-"&FORMAT(maxmonth,"MMM")&"'"&FORMAT(maxmonth,"YY")

Create a matirx and you will see:

v-kelly-msft_0-1614845842768.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

BA_Pete
Super User
Super User

Hi @Dee ,

 

I would start by creating a calendar table with your Year/Qtr and Quarter Range dimensions programmatically defined against dates.

What I mean by this would be columns in your calendar table that, given the date in each row, would output which Year/Quarter that date pertains to, and/or which quarter month range that date pertains to.

 

I would then delete the top row of your Excel import to remove the Year/Qtr value.

 

Next, I'd multi-select the four values columns (A, B, C, D) and select 'Unpivot other columns' from the ribbon. This will put all of your quarter month ranges into one column.

 

I'd then then try to isolate the first month from your range to convert to a date. In Power Query you could extract text before delimiter "-" into a new column, then change this to Date type. PQ should be smart enough to convert this to dates showing the first date of each of your months e.g. 01/01/2020.

 

Next relate your new calendar table from calendar[Date] to your new "First day of the quarter date" field. Use your Year/Quarter and Quarter Month Range fields from your calendar table on any visuals that you want to show by these dimensions.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 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.

October NL Carousel

Fabric Community Update - October 2024

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