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! Learn more

Reply
Kokkanti
Frequent Visitor

How to divide two years data in to every 6 months once in in power bi

Hi Team,
we have a requirement like we need to show the last two years data in x axis 
here date should calculate like current month to back 6 months.like that we need to show two years data in 4 categories.
Ex: we are in march month now we need to show march 2023 to october 2022.
same like september2022 to April 2022, March 2022 to October 2021,Septemeber 2021 to April 2021.
If we moved to April month dynamically months need to change .
Attached the pic :

Kokkanti_0-1678115037444.png

 



Please help on the issue.
Thank you.

1 ACCEPTED SOLUTION
Kokkanti
Frequent Visitor

@v-yueyunzh-msft  Tqs For U r suggestion .
I have created calculated column like this and it's worked for me

6 Months =
if('Date Table'[Date]<=TODAY()&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-5, 1),
FORMAT(Today(),"MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-5, 1),"MMM-YYYY"),

if('Date Table'[Date]<=EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-7, 1),1)&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-11, 1),
FORMAT(EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-7, 1),1), "MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-11, 1),"MMM-YYYY"),

if('Date Table'[Date]<=EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-13, 1),1)&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-17, 1),

FORMAT(EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-13, 1),1), "MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-17, 1),"MMM-YYYY"),

if('Date Table'[Date]<=EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-19, 1),1)&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-23, 1),
FORMAT(EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-19, 1),1), "MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-23, 1),"MMM-YYYY")))))

View solution in original post

2 REPLIES 2
Kokkanti
Frequent Visitor

@v-yueyunzh-msft  Tqs For U r suggestion .
I have created calculated column like this and it's worked for me

6 Months =
if('Date Table'[Date]<=TODAY()&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-5, 1),
FORMAT(Today(),"MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-5, 1),"MMM-YYYY"),

if('Date Table'[Date]<=EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-7, 1),1)&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-11, 1),
FORMAT(EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-7, 1),1), "MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-11, 1),"MMM-YYYY"),

if('Date Table'[Date]<=EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-13, 1),1)&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-17, 1),

FORMAT(EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-13, 1),1), "MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-17, 1),"MMM-YYYY"),

if('Date Table'[Date]<=EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-19, 1),1)&&'Date Table'[Date]>=DATE(YEAR(TODAY()), MONTH(TODAY())-23, 1),
FORMAT(EOMONTH(DATE(YEAR(TODAY()), MONTH(TODAY())-19, 1),1), "MMM-YYYY")&"-"&FORMAT(DATE(YEAR(TODAY()), MONTH(TODAY())-23, 1),"MMM-YYYY")))))
v-yueyunzh-msft
Community Support
Community Support

Hi , @Kokkanti 

According to your description, you want to show the four dimension in the x-axis and it need to dynamic show?

That is, judge based on today's date, and then generate 4 dates and put them on your visual.

If this , i think you can create a calculated table(If you need to put on the x-axis , you need to have a column in the table) as this dimension, you can try to use the TODAY() and EOMONTH  to generate this table .And use measure to show the value in your visual .

For more information, you can refer to :
EOMONTH function (DAX) - DAX | Microsoft Learn

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

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 Kudoed Authors