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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
SoniaShankar
New Member

Measures for half-year sales

Hi All

Can anyone help how to create measures for half-year sales like H1 and H2 for both Current year and Previous year please.

Thanks in Advance,

Sonia

1 ACCEPTED SOLUTION
FarhanJeelani
Super User
Super User

Hi @SoniaShankar ,

 

Define Half-Year Logic

To separate H1 (January to June) and H2 (July to December), you can use the MONTH function.

Current Year H1 and H2

Create measures for H1 and H2 sales for the current year.

H1 Sales Current Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) <= 6,
    YEAR(Sales[Date]) = YEAR(TODAY())
)

H2 Sales Current Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) > 6,
    YEAR(Sales[Date]) = YEAR(TODAY())
)

Previous Year H1 and H2

To calculate for the previous year, modify the YEAR filter accordingly:

H1 Sales Previous Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) <= 6,
    YEAR(Sales[Date]) = YEAR(TODAY()) - 1
)

H2 Sales Previous Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) > 6,
    YEAR(Sales[Date]) = YEAR(TODAY()) - 1
)

Optional Total Half-Year Sales

If you'd like to create a combined measure for total half-year sales for both periods, you can sum up the respective measures:

Total H1 Sales = [H1 Sales Current Year] + [H1 Sales Previous Year]
Total H2 Sales = [H2 Sales Current Year] + [H2 Sales Previous Year]

 

Please mark this post as solution if it helps you. Appreciate Kudos.

 

View solution in original post

4 REPLIES 4
FarhanJeelani
Super User
Super User

Hi @SoniaShankar ,

 

Define Half-Year Logic

To separate H1 (January to June) and H2 (July to December), you can use the MONTH function.

Current Year H1 and H2

Create measures for H1 and H2 sales for the current year.

H1 Sales Current Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) <= 6,
    YEAR(Sales[Date]) = YEAR(TODAY())
)

H2 Sales Current Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) > 6,
    YEAR(Sales[Date]) = YEAR(TODAY())
)

Previous Year H1 and H2

To calculate for the previous year, modify the YEAR filter accordingly:

H1 Sales Previous Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) <= 6,
    YEAR(Sales[Date]) = YEAR(TODAY()) - 1
)

H2 Sales Previous Year = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    MONTH(Sales[Date]) > 6,
    YEAR(Sales[Date]) = YEAR(TODAY()) - 1
)

Optional Total Half-Year Sales

If you'd like to create a combined measure for total half-year sales for both periods, you can sum up the respective measures:

Total H1 Sales = [H1 Sales Current Year] + [H1 Sales Previous Year]
Total H2 Sales = [H2 Sales Current Year] + [H2 Sales Previous Year]

 

Please mark this post as solution if it helps you. Appreciate Kudos.

 

Appreciate your help @FarhanJeelani 

I have another issue in creating a measure to calculate sales for the remaining period of the year.
I am a beginner so please ignore my innonce when asking questions

I have table Sales which has data from 2022-1-1 until 2024-12-29 and I have to calculate Year-to-Go (YTG) Sales, I dont have goal/target value for 2024 and I donno how should I assume it.

Hi @SoniaShankar ,

No worries at all! Everyone starts somewhere, and asking questions is the best way to learn. Let me help you with your "Year-to-Go" (YTG) Sales calculation.

Since you don't have a specific goal or target value for 2024, you can calculate YTG Sales as the sum of sales for the remaining period of the current year based on today's date. Here's how you can do it using DAX:

Measure for Year-to-Go (YTG) Sales:

YTG Sales = 
CALCULATE(
    SUM(Sales[SalesAmount]),
    Sales[Date] >= TODAY(),
    YEAR(Sales[Date]) = YEAR(TODAY())
)

Explanation:

  1. Sales[Date] >= TODAY(): This filters the rows to only include dates from today onward.
  2. YEAR(Sales[Date]) = YEAR(TODAY()): Ensures you only sum sales for the current year.

If You Want to Extend This Logic:

  • For YTG Sales for future years, you can modify the logic to include dates beyond this year by adjusting the filter for the YEAR function.
  • If you eventually get target or goal data, you can compare the calculated YTG Sales against the target to track progress.

Let me know if you need further clarification or adjustments! 😊

 

Please mark this post as solution if it helps you. Appreciate Kudos.

Thank you for being kind. @FarhanJeelani 
Is it suppose to retrun any value, I dont see anything post 29 Dec 2024

SowmyaTupakula_0-1736936427648.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.