Forum Discussion
Repeat values based on other value
Hi all,
I want to repeat values as you can see in column "should be plan". It should be based on column "Fact". If in this column there are any values so plan should be repeated. "Plan" i have 1 value for whole month, so you can try to use logic with "first-day-of-month" = 1.
This i use, but it did not work: Matrix Plan = if([Fact]<>"";CALCULATE(sum('table1'[Plan]);'Date'[Day Of Month]="1";""))
| DSR Code | Date | Fact | Plan | Should be plan |
| RRUM116 | 01.08.2017 | 173 | 194 | 194 |
| RRUM116 | 07.08.2017 | 177 | 194 | |
| RRUM116 | 08.08.2017 | |||
| RRUM116 | 14.08.2017 | 3 | 194 | |
| RRUM116 | 15.08.2017 | |||
| RRUM116 | 21.08.2017 | 3 | 194 | |
| RRUM116 | 28.08.2017 | 3 | 194 |
Next, i have tried this: Matrix Plan = SWITCH(TRUE();isblank([Fact]);blank();CALCULATE('table1'[Plan];'Date'[Day Of Month]=1))
But it returned me:
| DSR Code | Date | Fact | Plan | Should be plan |
| RRUM116 | 01.08.2017 | 173 | 194 | 194 |
| RRUM116 | 07.08.2017 | 177 | 0 | |
| RRUM116 | 08.08.2017 | |||
| RRUM116 | 14.08.2017 | 3 | 0 | |
| RRUM116 | 15.08.2017 | |||
| RRUM116 | 21.08.2017 | 3 | 0 | |
| RRUM116 | 28.08.2017 | 3 | 0 |
Almost as i want :D
12 Replies
- Zubair_MuhammadCommunity Champion
Hi idontexist
Try this calculated Column
Should_be_plan = VAR FirstValue = CALCULATE ( VALUES ( TableName[Plan] ), FILTER ( ALL ( Tablename ), MONTH ( TableName[Date] ) = MONTH ( EARLIER ( TableName[Date] ) ) && TableName[Date] = MINX ( FILTER ( ALL ( TableName ), MONTH ( TableName[Date] ) = MONTH ( EARLIER ( TableName[Date] ) ) ), TableName[Date] ) ) ) RETURN IF ( NOT ( ISBLANK ( TableName[Fact] ) ), FirstValue )- idontexistHelper I
I've tried and it did not work. Red value below, it marks me as wrong. So formula do nothing.
Should_be_plan = VAR FirstValue = CALCULATE ( VALUES ( TableName[Plan] ), FILTER ( ALL ( Tablename ), MONTH ( TableName[Date] ) = MONTH ( EARLIER ( TableName[Date] ) ) && TableName[Date] = MINX ( FILTER ( ALL ( TableName ), MONTH ( TableName[Date] ) = MONTH ( EARLIER ( TableName[Date] ) ) ), TableName[Date] ) ) ) RETURN IF ( NOT ( ISBLANK ( TableName[Fact] ) ), FirstValue )
- v-chuncz-msftCommunity Support
You may refer to the following DAX.
Column = VAR y = YEAR ( Table1[Date] ) VAR m = MONTH ( Table1[Date] ) RETURN IF ( NOT ( ISBLANK ( Table1[Fact] ) ), LOOKUPVALUE ( Table1[Plan], Table1[DSR Code], Table1[DSR Code], Table1[Date], DATE ( y, m, 1 ) ) )- idontexistHelper I
formulae YEAR and MONTH want to get date in format. Not from column.
So this isn't working for me :(
- Zubair_MuhammadCommunity Champion