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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MikeCheng
Regular Visitor

how to calculate pervious 6 month when date column in a Matrix

Hi all

 

how to calculate pervious 6 month when date column is text format?

 

here is the sample data link:

https://docs.google.com/spreadsheets/d/13WJvIqLFjyzkP9cEK4QychWAwjGcio5m/edit?usp=sharing&ouid=11255...

 

 

I have these 2 calculations:

previous 6 month sum =
CALCULATE (
    SUM('Raw data'[acture amount]),
    DATESINPERIOD ( 'Raw data'[年月].[Date]MAX ( 'Raw data'[年月].[Date] ), -6MONTH )
)
 
actural amount x180 divided by pervious 6 month sum = DIVIDE([acture amountx180][previous 6 month sum])
 
when I use date hierarchy, the numbers are correct but it become 3 layers Matrix, it is too hight
MikeCheng_0-1758595669516.png

 

 

But when I don't use the date hierarchy, the high of the Matrix is correct, but the numbers are wrong

 

MikeCheng_1-1758595864618.png

 

 

please help me build a Matrix which has only 2 layer with yyyy-mm format and the correct number

 

sample data link is provided

 

Best regards,

Mike

1 ACCEPTED SOLUTION
kushanNa
Super User
Super User

Hi @MikeCheng 

 

are you looking for an output similar to this ? 

 

kushanNa_0-1758607584767.png

if that what you are looking for i have attached the pbix file for your reference 

 

 

View solution in original post

6 REPLIES 6
v-veshwara-msft
Community Support
Community Support

Hi @MikeCheng ,

Just checking in to see if you query is resolved and if any responses were helpful.
Otherwise, feel free to reach out for further assistance.

Thank you.

v-veshwara-msft
Community Support
Community Support

Hi @MikeCheng ,

Thanks for reaching out to Microsoft Fabric Community.

Also, thanks @kushanNa  for your inputs and suggestions.

@MikeCheng , just wanted to check if the solution provided has addressed your needs and if you have considered the benefits of creating a Date table as mentioned by @kushanNa .

 

As mentioned, using a separate Date table is not mandatory, but it helps simplify calculations like YTD, QTD, and moving averages. This ensures your measures return correct results even when the column in your Matrix is in yyyy-mm format, keeping the Matrix at two layers.

 

Please reach out for further assistance.

Thank you.

kushanNa
Super User
Super User

Hi @MikeCheng 

 

are you looking for an output similar to this ? 

 

kushanNa_0-1758607584767.png

if that what you are looking for i have attached the pbix file for your reference 

 

 

yes, this is what I am Looking for, can you explain why to create another date table?

Hi  kushanNa

 

yes, this is what I looking for, can you explain why does it need to create another date table?

 

Hi @MikeCheng 

 

I believe it’s not always a must to create a Date table, but I usually create one when troubleshooting these types of scenarios since it makes things less complicated. Also, if you plan to do more time intelligence (YTD, QTD, moving averages, etc.), having a Date table will save you a lot of headaches.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors