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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
tockert
Regular Visitor

PreviousMonth Help

I have a table called Production.

In this table, I have columns with the months of the year and ending with a column called Year Total.

I need to pull the data from the previous month column for a formula for a rate.

My formula worked for the Year Total but not been able to figure out how to get the data from the previous month column.

 

Thanks

 

Todd

1 ACCEPTED SOLUTION

Hi @tockert 

Add MonthNo column for your table.Then you may get the PreviousMonth's production with below measure.

Measure =
CALCULATE (
    SUM ( 'Table'[Production] ),
    FILTER ( ALL ( 'Table' ), 'Table'[MonthNo] = MAX ( 'Table'[MonthNo] ) - 1 )
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi Todd,

 

Can you unpivot the data? 

 

If so, you can use the unpivoted month column as a date the date field where you can use the following function in dax to sum previous month 

 

https://docs.microsoft.com/en-us/dax/previousmonth-function-dax 

 

 

This is what the data looks like from the source record.

Year, Jan, Feb, Mar and so on until the last column is Year Total.

 

The year is the current year, and then production numbers are listed for each month. 

Capture.JPG

 

I have the ability to take this data prior to pulling it into Power BI to change the months and production numbers into 2 columns.

Not sure what you meant by "unpivot the data."

 

If I do this with the data prior to the import, I think this will work.

MonthProduction
JAN5653758
FEB5106620
MAR5653758
APR0
MAY0
JUN0
JUL0
AUG0
SEP0
OCT0
NOV0
DEC

0

 

Thanks

 

Todd

Hi @tockert 

Add MonthNo column for your table.Then you may get the PreviousMonth's production with below measure.

Measure =
CALCULATE (
    SUM ( 'Table'[Production] ),
    FILTER ( ALL ( 'Table' ), 'Table'[MonthNo] = MAX ( 'Table'[MonthNo] ) - 1 )
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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