Forum Discussion
pg1980
Helper II
3 years agoSquare Matrix
Hi everyone! I have to be able to make a analysis in a matrix visual. In this analysis I have to sum up the quantity values by “year-month New” and go substracting this number to the total quantity ...
- 3 years ago
Hi pg1980
Please refer to attached sample file with the proposed solutionCurrent Quantity = VAR MonthNew = SELECTEDVALUE ( 'Table'[year-month New] ) VAR MonthsShift = SELECTEDVALUE ( Months[Value] ) VAR MonthOut = EOMONTH ( MonthNew, MonthsShift - 2 ) + 1 VAR QtyNew = SUM ( 'Table'[Quantity] ) VAR QtyOut = CALCULATE ( SUM ( 'Table'[Quantity] ), COALESCE ( 'Table'[year-month Out], DATE ( 2050, 1, 1 ) ) <= MonthOut ) RETURN QtyNew - QtyOutThis is based on the assumption that year-month is date format (start of month). Also the expected results of July do not seem to be reasonable as the sample data data says 1 in in October and 1 out in October. However I have adjusted the sample data so that 1 in in July and 1 out in October.
tamerj1
Community Champion
3 years agoHi pg1980
Please refer to attached sample file with the proposed solution
Current Quantity =
VAR MonthNew = SELECTEDVALUE ( 'Table'[year-month New] )
VAR MonthsShift = SELECTEDVALUE ( Months[Value] )
VAR MonthOut = EOMONTH ( MonthNew, MonthsShift - 2 ) + 1
VAR QtyNew = SUM ( 'Table'[Quantity] )
VAR QtyOut =
CALCULATE (
SUM ( 'Table'[Quantity] ),
COALESCE ( 'Table'[year-month Out], DATE ( 2050, 1, 1 ) ) <= MonthOut
)
RETURN
QtyNew - QtyOut
This is based on the assumption that year-month is date format (start of month). Also the expected results of July do not seem to be reasonable as the sample data data says 1 in in October and 1 out in October. However I have adjusted the sample data so that 1 in in July and 1 out in October.