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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
crispy_sam
Frequent Visitor

Combining two measures into one. Inaccurate results.

I am trying to combine 2 calcluated measures into one calculated measure, but the resulting answer is incorrect. Please help me understand what is wrong or how do I go about creating a measure that would give the the correct result.
Sample .pbix file 

 

Date Table:

Date

WeekNum

Week

7/8/24

2

28

7/9/24

3

28

7/10/24

4

28

.

.

.

.

.

.

.

.

.

7/10/23

2

28

7/11/23

3

28

7/12/23

4

28

.

.

.


Measure 1: 

_SDLY Net Sales = 
VAR CurrentDayOfWeek = MAX('Date'[WeekNum])
VAR CurrentWeek = MAX('Date'[Week])
VAR LastYear = MAX('Date'[Year]) - 1
RETURN
CALCULATE(
    [Net Sales]
    , ALL('Date')
    , 'Date'[Week] = CurrentWeek
    , 'Date'[Day of Week Number] = CurrentDayOfWeek
    , 'Date'[Year] = LastYear
)

Measure 2: 

SDLY Net Sales = SUMX ( 'Date', [_SDLY Net Sales] )
 
Combined Measure:
Test SDLY = 
VAR CurrentDayOfWeek = MAX('Date'[Day of Week Number])
VAR CurrentWeek =  MAX('Date'[Week])
VAR LastYear = MAX('Date'[Year]) - 1
VAR Result =
    CALCULATE(
            [Net Sales],
            ALL('Date'),
            'Date'[Week] = CurrentWeek,
            'Date'[Day of Week Number] = CurrentDayOfWeek,
            'Date'[Year] = LastYear
        )
RETURN
SUMX('Date', Result)

 

Resulting Table:

Screenshot 2024-07-22 105957.png

 

  • My goal is find the total of a metric (Net Sales) for last year during the same period.
  • The way "same period" is calcluated is different, based on the date filter, for a particular day it selects a date from last year that has the same week number for the year and day number for that week. So, same day last year for 7/8/24 is 7/10/23 as the two dates fall on week-28 and is the 2nd day of the week during their respectful year.
  • Test SDLY is a combined measure, although the individual values match the values of the two measures, the totals do not match.
  • I intented to incorporate this meaure into a calculation group in the future.
2 REPLIES 2
Ritaf1983
Super User
Super User

Hi @crispy_sam 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Added a link to .pbix file in main post. 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.