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

Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.

Reply
echaize
Frequent Visitor

Calculate period over period

Hello,
I'm trying to calculate and compare two measures.

The first "Qty Sum" is the SUM of my fact table on a period defined by a "between" date sclicer and the second is the same measure on the previous period (Qty Sum PP).

For example, if the period is from 11/13/2023 to 11/19/2023 (7 days), I would like to calculate the second measure as the sum on the previous period i.e. 11/06/2023 to 11/12/2023.

If the user selects another period, the measure have to calculate the length of the period and returns the sum of my fact table on this period.

My date table is named "Dates". My fact table is named Facts with a column Date and a column Qty.

 

The first measure is "Qty Sum" defined as :

Qty Sum =
SUM(Facts[Qty])

 

The second measure is :

Qty Sum PP =
VAR PeriodEnd = FIRSTDATE('Dates'[Date])-1
VAR PeriodStart =
PeriodEnd -
DATEDIFF(
FIRSTDATE('Dates'[Date]),
LASTDATE('Dates'[Date]),
DAY
)
VAR Result =
CALCULATE(
[Qty Sum],
DATESBETWEEN('Dates'[Date],
PeriodStart,PeriodEnd
)
)
Return Result

 

The second measure does not work. It returns blank.

echaize_0-1700302258164.png

 

Any help would be appreciated!

1 ACCEPTED SOLUTION
2 REPLIES 2
lbendlin
Super User
Super User

I'm trying to calculate and compare two measures.

You cannot measure a measure. Implement your business logic in a single measure.

 

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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

Top Kudoed Authors