Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
Solved! Go to 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 ) )
Regards,
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.
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.
Month | Production |
JAN | 5653758 |
FEB | 5106620 |
MAR | 5653758 |
APR | 0 |
MAY | 0 |
JUN | 0 |
JUL | 0 |
AUG | 0 |
SEP | 0 |
OCT | 0 |
NOV | 0 |
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 ) )
Regards,
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
64 |
User | Count |
---|---|
135 | |
122 | |
101 | |
71 | |
61 |