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.
Hello,
I have a report showing articles and a inventory value per month. The month information is stored in one column and contains e.g. 01-2019, 02-2019.
Article 1 / 01-2019: 100 02-2019: 200
I would like to calculate Table[inventory value] as difference for the last period and the previous one = 200-100 = +100.
Solved! Go to Solution.
Hi
Create a date table and create a relationship between this date table and your table.
CALENDAR = ADDCOLUMNS ( CALENDARAUTO (), "MM-YY", FORMAT ( [Date], "mm-yyyy" ), "year", YEAR ( [Date] ), "month", MONTH ( [Date] ) )
Create measures in your table,
Measure = VAR noblank = CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'CALENDAR', 'CALENDAR'[Date] <> BLANK () ) ) RETURN IF ( SUM ( 'Table'[value] ) = BLANK (), CALCULATE ( 0, FILTER ( 'CALENDAR', 'CALENDAR'[Date] = BLANK () ) ), noblank )
Measure 3 = [Measure]-[Measure 2]
Add [article] and [Measure 3] in a table or matrix, you will get the result as expected.
Best Regards
Maggie
Hi
Create a date table and create a relationship between this date table and your table.
CALENDAR = ADDCOLUMNS ( CALENDARAUTO (), "MM-YY", FORMAT ( [Date], "mm-yyyy" ), "year", YEAR ( [Date] ), "month", MONTH ( [Date] ) )
Create measures in your table,
Measure = VAR noblank = CALCULATE ( SUM ( 'Table'[value] ), FILTER ( 'CALENDAR', 'CALENDAR'[Date] <> BLANK () ) ) RETURN IF ( SUM ( 'Table'[value] ) = BLANK (), CALCULATE ( 0, FILTER ( 'CALENDAR', 'CALENDAR'[Date] = BLANK () ) ), noblank )
Measure 3 = [Measure]-[Measure 2]
Add [article] and [Measure 3] in a table or matrix, you will get the result as expected.
Best Regards
Maggie
Hi Maggie,
thank you for your help. I got the first part working.
In the measure I get the following error, which I am clueless how to resolve: "The syntax for 'FILTER' is incorrect."
I replace TABLE with my tables name.
Thanks again for your help.
Hi @kgr
Make sure you create a measure, also you create relationships for the calendar table and your data table.
If you are unable to slove this, please share the screenshot which can make me clear more about this.
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Here comes the screenshot. Thanks again for your help.
Hi @kgr
Can You provide a data sample?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |