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

Win a FREE 3 Day Ticket to FabCon Vienna. Apply now

Reply
ftorres
Helper I
Helper I

variation without date dimension

Hi everyone,

 

I'm trying to create a measure that brings me the variation.

Like this table below. But I would like instead of accumulating I would like the variation between them. I know with the date functions but the account period is not a date type.

% Previous Month = CALCULATE([Actual Cost],FILTER(ALLSELECTED(Cost),Cost[account_period]<= MAX(Cost[account_period])))

report.png

1 ACCEPTED SOLUTION
ssugar
Resolver III
Resolver III

If your accounting period is a text field, you can do this:

 

Previous Month = CALCULATE([Actual Cost],FILTER(ALLSELECTED(Table1),IF(RIGHT(SELECTEDVALUE(Table1[Accounting Period]), 2) = "01", VALUE(SELECTEDVALUE(Table1[Accounting Period])) = VALUE(Table1[Accounting Period]) + 89,VALUE(SELECTEDVALUE(Table1[Accounting Period])) = VALUE(Table1[Accounting Period]) + 1)))

 

 

If it's a numeric field, you can do this:

 

Previous Month = CALCULATE([Actual Cost],FILTER(ALLSELECTED(Table1),IF(RIGHT(FORMAT(SELECTEDVALUE(Table1[Accounting Period]), "General Number"), 2) = "01", SELECTEDVALUE(Table1[Accounting Period]) = Table1[Accounting Period] + 89,SELECTEDVALUE(Table1[Accounting Period]) = Table1[Accounting Period] + 1)))

 

 

Then to get the %:

 

% Previous Month = IF([Previous Month] = BLANK(), "NA", [Actual Cost] / [Previous Month])

 

 

Note that this will only work if you have no gaps in your Accounting Periods.  In your example data, you have a gap between 201111 and 201202, so this will break down there. 

 

link to a pbix file with working solution for first 4 rows of your example data:

https://github.com/ssugar/PowerBICommunity/raw/master/community-sol-265464.pbix

View solution in original post

1 REPLY 1
ssugar
Resolver III
Resolver III

If your accounting period is a text field, you can do this:

 

Previous Month = CALCULATE([Actual Cost],FILTER(ALLSELECTED(Table1),IF(RIGHT(SELECTEDVALUE(Table1[Accounting Period]), 2) = "01", VALUE(SELECTEDVALUE(Table1[Accounting Period])) = VALUE(Table1[Accounting Period]) + 89,VALUE(SELECTEDVALUE(Table1[Accounting Period])) = VALUE(Table1[Accounting Period]) + 1)))

 

 

If it's a numeric field, you can do this:

 

Previous Month = CALCULATE([Actual Cost],FILTER(ALLSELECTED(Table1),IF(RIGHT(FORMAT(SELECTEDVALUE(Table1[Accounting Period]), "General Number"), 2) = "01", SELECTEDVALUE(Table1[Accounting Period]) = Table1[Accounting Period] + 89,SELECTEDVALUE(Table1[Accounting Period]) = Table1[Accounting Period] + 1)))

 

 

Then to get the %:

 

% Previous Month = IF([Previous Month] = BLANK(), "NA", [Actual Cost] / [Previous Month])

 

 

Note that this will only work if you have no gaps in your Accounting Periods.  In your example data, you have a gap between 201111 and 201202, so this will break down there. 

 

link to a pbix file with working solution for first 4 rows of your example data:

https://github.com/ssugar/PowerBICommunity/raw/master/community-sol-265464.pbix

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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