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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Skunny11
Frequent Visitor

Parallelperiod -1, Month Showing current months sum instead of last month

Hey Everyone, so i have a measure for both total sum of a field and a measure for that same field except for the previous month. Yet in the Table visualization they come out to be the same number for the given month.

 

I have a date field in this table that is not contiguous (meaning records are added on the 1st of each month and given a date for that day), I have formatted this date field so that it shows the month and year so dec 18, jan 19, feb 19, etc...

 

Total = CALCULATE(SUM(mytable[numbertosum]))

Previous month = CALCULATE(SUM(mytable[numbertosum]), PARALLELPERIOD(mytable[date],-1,MONTH))

 

What i am seeing is the following:

 

Date      |  sum   |   previous month sum

nov 18   |  200    |             200

dec 18   |  800    |             800

Jan 19   |  300    |             300

Feb 19   |  400    |             400

 

When i am expecting to see:

 

Date      |  sum   |   previous month sum

nov 18   |  200    |               0

dec 18   |  800    |             200

Jan 19   |  300    |             800

Feb 19   |  400    |             300

 

I have tried PREVIOUSMONTH which doesnt return any sums for previous month, I have tried DATEADD which returns the same as parallelperiod.

 

Any help on this would be greatly appriciated.

1 ACCEPTED SOLUTION

I figured out what was happening.

 

It had to do with the way I was filtering other fields in the measure. I didnt include those filters because I didnt think they were relavant to the problem.

 

My actual measure used to be this:

 

Measure_Previous_Month = 
CALCULATE
( 
SUM(mytable[myitemtocount]), FILTER ( mytable, PARALLELPERIOD(mytable[Date],-1,MONTH) && (mytable[edition] = "myedition") && (mytable[type] = "mytype" || mytable[type] = "mytype2") )
)

When i got rid of that nested filter and just did it the regular way it ended up working as intended, not sure i understand the logic on why.

 

Measure_Previous_Month = 
CALCULATE
( 
    SUM(mytable[myitemtocount]), 
    PARALLELPERIOD(mytable[Date],-1,MONTH),
    (mytable[edition] = "myedition"), 
    (mytable[type] = "mytype" || mytable[type] = "mytype2")
)

View solution in original post

7 REPLIES 7
evandrocunico
Resolver III
Resolver III
Anonymous
Not applicable

You need to have a dedicated Date table, marked as a such, then related to your fact table. Then use the columns from that table in your measures

How to Mark as Date Table.pnghttps://docs.microsoft.com/en-us/dax/time-intelligence-functions-dax

I cant create a separate date table because the dates are not contiguous for that field in the other table. 

 

I get the Error: The date column must have unique values. The date column can't have gaps in dates.

 

Also I have already tried to use DATEADD and it does the same thing as parallelperiod

Anonymous
Not applicable

Hi,

 

Create a date table using the below formula and create a relationship it with your existing table:

 

Table:

 

Calender = CALENDAR(MIN('TableName'[ColumnName]), MAX('TableName'[ColumnName]))
 
Add the following columns to the Calender table:
1) FY = if(MONTH(Calander[Date])<=3,YEAR(Calander[Date]),YEAR(Calander[Date]))
2) Month = FORMAT(Calander[Date], "mmmm")
 
Once you create this table with above mentioned the columns and create a relationship between both the tables, you'd be able to get the result you're looking.
 
Regards,
Mahesh

I created the new table as you listed, created a relationship from the date field in my first table and the calendar date field. This does not fix my problem, i am still seeing the same behavior, only now the same behavior is being displayed while using PREVIOUSMONTH as well as DATEADD and PARALLELPERIOD. All so the same data as the current month in the previous month column.

Anonymous
Not applicable

@Skunny11 

Can you upload a sample pbix?

I figured out what was happening.

 

It had to do with the way I was filtering other fields in the measure. I didnt include those filters because I didnt think they were relavant to the problem.

 

My actual measure used to be this:

 

Measure_Previous_Month = 
CALCULATE
( 
SUM(mytable[myitemtocount]), FILTER ( mytable, PARALLELPERIOD(mytable[Date],-1,MONTH) && (mytable[edition] = "myedition") && (mytable[type] = "mytype" || mytable[type] = "mytype2") )
)

When i got rid of that nested filter and just did it the regular way it ended up working as intended, not sure i understand the logic on why.

 

Measure_Previous_Month = 
CALCULATE
( 
    SUM(mytable[myitemtocount]), 
    PARALLELPERIOD(mytable[Date],-1,MONTH),
    (mytable[edition] = "myedition"), 
    (mytable[type] = "mytype" || mytable[type] = "mytype2")
)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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