Forum Discussion
Create line graph for only Month end values based on date slicer
- 2 years ago
Step 0: I use your data below.
Step 1: I add a 'Month' column and a 'Flag' column.
Month = MONTH([Date])
Flag = IF([Date]=CALCULATE(MAX(DATA[Date]),ALLEXCEPT('DATA','DATA'[Month])),1,0)
Step 2: I make a graph and set 'Flag' filter.
- Anonymous2 years ago
Thanks for the reply from mickey64 , 3CloudThomas and andrezmar , please allow me to provide another insight:
Hi, Anonymous
Regarding the issue you raised, my solution is as follows:
1.First I have created the following table and the column names and data are the data you have given:
2.Create calculated column references:
LastWorkdayOfMonth = VAR LastDay = EOMONTH('Table'[Date], 0) VAR LastWorkday = SWITCH( WEEKDAY(LastDay, 2), 6, LastDay - 1, 7, LastDay - 2, LastDay ) RETURN LastWorkday3. Below are the measure I've created for your needs:
MEASURE A = VAR LastDay1 = EOMONTH ( MAX ( 'Table (2)'[selcet] ), 0 ) VAR LastDay2 = EOMONTH ( MAX ( 'Table (2)'[selcet] ), -1 ) VAR LastWorkday1 = SWITCH ( WEEKDAY ( LastDay1, 2 ), 6, LastDay1 - 1, 7, LastDay1 - 2, LastDay1 ) VAR LastWorkday2 = SWITCH ( WEEKDAY ( LastDay2, 2 ), 6, LastDay2 - 1, 7, LastDay2 - 2, LastDay2 ) RETURN IF ( MAX ( 'Table (2)'[selcet] ) = LastWorkday1, CALCULATE ( SUM ( 'Table'[Metric A] ), 'Table'[LastWorkdayOfMonth] = MAX ( 'Table (2)'[selcet] ) ), CALCULATE ( SUM ( 'Table'[Metric A] ), 'Table'[LastWorkdayOfMonth] = LastWorkday2 ) )Measure B = VAR LastDay1 = EOMONTH ( MAX ( 'Table (2)'[selcet] ), 0 ) VAR LastDay2 = EOMONTH ( MAX ( 'Table (2)'[selcet] ), -1 ) VAR LastWorkday1 = SWITCH ( WEEKDAY ( LastDay1, 2 ), 6, LastDay1 - 1, 7, LastDay1 - 2, LastDay1 ) VAR LastWorkday2 = SWITCH ( WEEKDAY ( LastDay2, 2 ), 6, LastDay2 - 1, 7, LastDay2 - 2, LastDay2 ) RETURN IF ( MAX ( 'Table (2)'[selcet] ) = LastWorkday1, CALCULATE ( SUM ( 'Table'[Metric B] ), 'Table'[LastWorkdayOfMonth] = MAX ( 'Table (2)'[selcet] ) ), CALCULATE ( SUM ( 'Table'[Metric B] ), 'Table'[LastWorkdayOfMonth] = LastWorkday2 ) )4.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Many thanks for the response mickey64. I dont want August to be on graph as August month is not yet complete. Also when user selects any date in August, it should only display till July Monthends.
With the formula, even the current last day (currently some day in August) is also getting flag as 1.
Is there a way to control this?
Thanks
Thanks for the reply from mickey64 , 3CloudThomas and andrezmar , please allow me to provide another insight:
Hi, Anonymous
Regarding the issue you raised, my solution is as follows:
1.First I have created the following table and the column names and data are the data you have given:
2.Create calculated column references:
LastWorkdayOfMonth =
VAR LastDay = EOMONTH('Table'[Date], 0)
VAR LastWorkday =
SWITCH(
WEEKDAY(LastDay, 2),
6, LastDay - 1,
7, LastDay - 2,
LastDay
)
RETURN LastWorkday
3. Below are the measure I've created for your needs:
MEASURE A =
VAR LastDay1 =
EOMONTH ( MAX ( 'Table (2)'[selcet] ), 0 )
VAR LastDay2 =
EOMONTH ( MAX ( 'Table (2)'[selcet] ), -1 )
VAR LastWorkday1 =
SWITCH ( WEEKDAY ( LastDay1, 2 ), 6, LastDay1 - 1, 7, LastDay1 - 2, LastDay1 )
VAR LastWorkday2 =
SWITCH ( WEEKDAY ( LastDay2, 2 ), 6, LastDay2 - 1, 7, LastDay2 - 2, LastDay2 )
RETURN
IF (
MAX ( 'Table (2)'[selcet] ) = LastWorkday1,
CALCULATE (
SUM ( 'Table'[Metric A] ),
'Table'[LastWorkdayOfMonth] = MAX ( 'Table (2)'[selcet] )
),
CALCULATE (
SUM ( 'Table'[Metric A] ),
'Table'[LastWorkdayOfMonth] = LastWorkday2
)
)Measure B =
VAR LastDay1 =
EOMONTH ( MAX ( 'Table (2)'[selcet] ), 0 )
VAR LastDay2 =
EOMONTH ( MAX ( 'Table (2)'[selcet] ), -1 )
VAR LastWorkday1 =
SWITCH ( WEEKDAY ( LastDay1, 2 ), 6, LastDay1 - 1, 7, LastDay1 - 2, LastDay1 )
VAR LastWorkday2 =
SWITCH ( WEEKDAY ( LastDay2, 2 ), 6, LastDay2 - 1, 7, LastDay2 - 2, LastDay2 )
RETURN
IF (
MAX ( 'Table (2)'[selcet] ) = LastWorkday1,
CALCULATE (
SUM ( 'Table'[Metric B] ),
'Table'[LastWorkdayOfMonth] = MAX ( 'Table (2)'[selcet] )
),
CALCULATE (
SUM ( 'Table'[Metric B] ),
'Table'[LastWorkdayOfMonth] = LastWorkday2
)
)
4.Here's my final result, which I hope meets your requirements.
Please find the attached pbix relevant to the case.
Best Regards,
Leroy Lu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.