Forum Discussion
Calculate first value for months
This is an example:
| Date | System | Value |
| 09.07.2020 | 1st | 266471,4 |
| 10.07.2020 | 1st | 266471,4 |
| 11.07.2020 | 1st | 266471,4 |
| 12.07.2020 | 1st | 266471,4 |
| 13.07.2020 | 1st | 266471,4 |
| 14.07.2020 | 1st | 266471,4 |
| 15.07.2020 | 1st | 266471,4 |
| 16.07.2020 | 1st | 266471,4 |
| 17.07.2020 | 1st | 266471,4 |
| 18.07.2020 | 1st | 266471,4 |
| 19.07.2020 | 1st | 266471,4 |
| 20.07.2020 | 1st | 266471,4 |
| 21.07.2020 | 1st | 266471,4 |
| 22.07.2020 | 1st | 266471,4 |
| 23.07.2020 | 1st | 266471,4 |
| 24.07.2020 | 1st | 266471,4 |
| 25.07.2020 | 1st | 266471,4 |
| 26.07.2020 | 1st | 266471,4 |
| 27.07.2020 | 1st | 266471,4 |
| 28.07.2020 | 1st | 266471,4 |
| 08.07.2020 | 2nd | 263707,1 |
| 09.07.2020 | 2nd | 263707,1 |
| 10.07.2020 | 2nd | 263707,1 |
| 11.07.2020 | 2nd | 263707,1 |
| 12.07.2020 | 2nd | 263707,1 |
| 13.07.2020 | 2nd | 263707,1 |
| 14.07.2020 | 2nd | 263707,1 |
| 15.07.2020 | 2nd | 263707,1 |
| 16.07.2020 | 2nd | 263707,1 |
| 17.07.2020 | 2nd | 263707,1 |
| 18.07.2020 | 2nd | 263707,1 |
| 19.07.2020 | 2nd | 263707,1 |
| 20.07.2020 | 2nd | 263707,1 |
| 21.07.2020 | 2nd | 263707,1 |
| 22.07.2020 | 2nd | 263707,1 |
| 23.07.2020 | 2nd | 263707,1 |
| 24.07.2020 | 2nd | 263707,1 |
| 25.07.2020 | 2nd | 263707,1 |
| 26.07.2020 | 2nd | 263707,1 |
| 27.07.2020 | 2nd | 263707,1 |
| 28.07.2020 | 2nd | 263707,1 |
| 29.07.2020 | 2nd | 263707,1 |
| 30.07.2020 | 2nd | 263707,1 |
| 31.07.2020 | 2nd | 263707,1 |
| 01.08.2020 | 2nd | 86292,86 |
| 02.08.2020 | 2nd | 86292,86 |
| 07.08.2020 | 2nd | 86292,86 |
| 03.08.2020 | 2nd | 86292,86 |
| 04.08.2020 | 2nd | 86292,86 |
| 05.08.2020 | 2nd | 86292,86 |
| 06.08.2020 | 2nd | 86292,86 |
| 29.07.2020 | 1st | 266471,4 |
| 30.07.2020 | 1st | 266471,4 |
| 31.07.2020 | 1st | 266471,4 |
| 01.08.2020 | 1st | 83528,57 |
| 02.08.2020 | 1st | 83528,57 |
| 03.08.2020 | 1st | 83528,57 |
| 04.08.2020 | 1st | 83528,57 |
| 05.08.2020 | 1st | 83528,57 |
| 06.08.2020 | 1st | 83528,57 |
| 07.08.2020 | 1st | 83528,57 |
Expected result without filters:
| 1st | 350000 |
| 2nd | 350000 |
That means that for each system with have 2 months 7 and 8 and for each month we get first value. E.g.
1st system - july 266471,4286 and august 83528,57143
2nd system - july 86292,85714 and august 263707,1429
If i use slicer on a date for ex only july it should show:
1st system - july 266471,4286
2nd system - july 86292,85714
I think it should calculate first value for selected month. Thank you for any help.
7 Replies
- vivran22Community Champion
Hello seinomozh ,
From what I could understand from the description shared, following is the recreation of your scenario:
Sample Data Table:
Date System Value 9-Jul-20 1st 9 10-Jul-20 1st 10 11-Jul-20 1st 11 12-Jul-20 1st 12 13-Jul-20 1st 13 14-Jul-20 1st 14 15-Jul-20 1st 15 16-Jul-20 1st 16 17-Jul-20 1st 17 18-Jul-20 1st 18 19-Jul-20 1st 19 20-Jul-20 1st 20 21-Jul-20 1st 21 22-Jul-20 1st 22 23-Jul-20 1st 23 24-Jul-20 1st 24 25-Jul-20 1st 25 26-Jul-20 1st 26 27-Jul-20 1st 27 28-Jul-20 1st 28 8-Jul-20 2nd 8 9-Jul-20 2nd 9 10-Jul-20 2nd 10 11-Jul-20 2nd 11 12-Jul-20 2nd 12 13-Jul-20 2nd 13 14-Jul-20 2nd 14 15-Jul-20 2nd 15 16-Jul-20 2nd 16 17-Jul-20 2nd 17 18-Jul-20 2nd 18 19-Jul-20 2nd 19 20-Jul-20 2nd 20 21-Jul-20 2nd 21 22-Jul-20 2nd 22 23-Jul-20 2nd 23 24-Jul-20 2nd 24 25-Jul-20 2nd 25 26-Jul-20 2nd 26 27-Jul-20 2nd 27 28-Jul-20 2nd 28 29-Jul-20 2nd 29 30-Jul-20 2nd 30 31-Jul-20 2nd 31 1-Aug-20 2nd 1 2-Aug-20 2nd 2 7-Aug-20 2nd 7 3-Aug-20 2nd 3 4-Aug-20 2nd 4 5-Aug-20 2nd 5 6-Aug-20 2nd 6 29-Jul-20 1st 29 30-Jul-20 1st 30 31-Jul-20 1st 31 1-Aug-20 1st 1 2-Aug-20 1st 2 3-Aug-20 1st 3 4-Aug-20 1st 4 5-Aug-20 1st 5 6-Aug-20 1st 6 7-Aug-20 1st 7 Measure:
First Value = VAR _MinDate = MIN('Table'[Date]) VAR _FirstValue = CALCULATE(FIRSTNONBLANK('Table'[Value],TRUE()),'Table'[Date] = _MinDate) RETURN _FirstValueResult:
Hope this helps.
Cheers!
Vivek
If it helps, please mark it as a solution. Kudos would be a cherry on the top 🙂
If it doesn't, then please share a sample data along with the expected results (preferably an excel file and not an image)
Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter- seinomozhFrequent Visitor
Hi vivran22
Not exactly. It calculates only first value for each system without date filter. E.g. for july only OR july and aug - same result.
Should be 350K for each row without filter. Below result works only for july dates.
Best guess - to create new column that gives "1" for first day per month for each system. Like:
Date System Value New column 09.07.2020 1st 266471,4 1 10.07.2020 1st 266471,4 11.07.2020 1st 266471,4 12.07.2020 1st 266471,4 13.07.2020 1st 266471,4 14.07.2020 1st 266471,4 15.07.2020 1st 266471,4 16.07.2020 1st 266471,4 17.07.2020 1st 266471,4 18.07.2020 1st 266471,4 19.07.2020 1st 266471,4 20.07.2020 1st 266471,4 21.07.2020 1st 266471,4 22.07.2020 1st 266471,4 23.07.2020 1st 266471,4 24.07.2020 1st 266471,4 25.07.2020 1st 266471,4 26.07.2020 1st 266471,4 27.07.2020 1st 266471,4 28.07.2020 1st 266471,4 29.07.2020 1st 266471,4 30.07.2020 1st 266471,4 31.07.2020 1st 266471,4 01.08.2020 1st 83528,57 1 02.08.2020 1st 83528,57 03.08.2020 1st 83528,57 04.08.2020 1st 83528,57 05.08.2020 1st 83528,57 06.08.2020 1st 83528,57 07.08.2020 1st 83528,57 08.07.2020 2nd 263707,1 1 09.07.2020 2nd 263707,1 10.07.2020 2nd 263707,1 11.07.2020 2nd 263707,1 12.07.2020 2nd 263707,1 13.07.2020 2nd 263707,1 14.07.2020 2nd 263707,1 15.07.2020 2nd 263707,1 16.07.2020 2nd 263707,1 17.07.2020 2nd 263707,1 18.07.2020 2nd 263707,1 19.07.2020 2nd 263707,1 20.07.2020 2nd 263707,1 21.07.2020 2nd 263707,1 22.07.2020 2nd 263707,1 23.07.2020 2nd 263707,1 24.07.2020 2nd 263707,1 25.07.2020 2nd 263707,1 26.07.2020 2nd 263707,1 27.07.2020 2nd 263707,1 28.07.2020 2nd 263707,1 29.07.2020 2nd 263707,1 30.07.2020 2nd 263707,1 31.07.2020 2nd 263707,1 01.08.2020 2nd 86292,86 1 02.08.2020 2nd 86292,86 03.08.2020 2nd 86292,86 04.08.2020 2nd 86292,86 05.08.2020 2nd 86292,86 06.08.2020 2nd 86292,86 07.08.2020 2nd 86292,86 Than easiest way - CALCULATE(SUM('Table'[Value]),'Table'[New_Column]=1)
- vivran22Community Champion
I did not understand the logic of 350k? How did you arrive at this value?
Cheers!
Vivek
Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter
- FrankATCommunity Champion
Hi seinomozh
I found the following solution:
First Value of Month = CALCULATE( MIN('Table'[Value]), FILTER( ALLEXCEPT('Table','Table'[System]), MIN('Table'[Date])='Table'[Date] ) )With kind regards from the town where the legend of the 'Pied Piper of Hamelin' is at home
FrankAT (Proud to be a Datanaut)- seinomozhFrequent Visitor
This is great, but it is not summarize if remove month. Idea is to create a measure that can show you proper value per choosen month. So if i choose 2 month (jul+aug) it should be 350K per system.
- AnonymousNot applicable
Hi seinomozh,
You can try to use the below formula to use system category and date filter to find out the minimum date and correspond value:
Measure = VAR minDate = CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED ( 'Table' ), VALUES ( 'Table'[Date] ), VALUES ( 'Table'[System] ) ) RETURN CALCULATE ( MIN ( 'Table'[Value] ), FILTER ( ALLSELECTED ( 'Table' ), [Date] = minDate ), VALUES ( 'Table'[System] ) )Regards,
Xiaoxin Sheng