Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi,
So i've got this visual where the current month (now September) is showing the MTD sales. When the month is over, the GS II MTD LY column should show the full month of sales for LY.
If the month hasn't occured yet, it should show a blank, which it does here - the problem arises, because the grand total is blank as well. I would like the grand total to show the sum of the GS II MTD LY column, to see how we are doing this year compared to FYTD last year.
This is the DAX for my GS II MTD LY measure:
Solved! Go to Solution.
@Jæver - It occured to me what you are trying to acheive this morning, so I have updated my earlier solution below.
This one should minus the current Month to date ONLY off of the LY total.
VAR MTD_SALES =
CALCULATE (
[Gross Sales II BC],
SAMEPERIODLASTYEAR (
DATESBETWEEN (
'Calendar'[Date],
STARTOFMONTH ( 'Calendar'[Date] ),
TODAY () - 1
)
)
)
VAR CurrentMonth =
MONTH ( TODAY () )
VAR DataMonth =
MONTH ( MAX ( 'Calendar'[Date] ) )
VAR CurrentYear =
YEAR ( TODAY () )
VAR DataYear =
YEAR ( MAX ( 'Calendar'[Date] ) )
VAR MTD_SALES_NOW =
CALCULATE (
MTD_SALES,
'Calendar'[Month_Number] = CurrentMonth
&& 'Calendar'[Year_Number] = CurrentYear
)
RETURN
SWITCH (
TRUE (),
HASONEVALUE ( 'Calendar'[MONTH-YEAR] ),
IF (
DataYear > CurrentYear
|| ( DataYear = CurrentYear
&& DataMonth > CurrentMonth ),
BLANK (),
MTD_SALES
),
[GSII LY] - MTD_SALES_NOW
)
If this works for you, please consider marking it as the solution.
Hi,
Thanks for the input. It does this to my visual, which isn't what i'm looking for, unfortunately.
@Jæver - You are missing a condition that accounts for the total. Try the DAX below, you just need to replace the value for your MONTH YEAR column inside HASONEVALUE
GS II MTD LY =
VAR MTD_SALES =
CALCULATE (
[Gross Sales II BC],
SAMEPERIODLASTYEAR (
DATESBETWEEN (
'Calendar'[Date],
STARTOFMONTH ( 'Calendar'[Date] ),
TODAY () - 1
)
)
)
VAR CurrentMonth =
MONTH ( TODAY () )
VAR DataMonth =
MONTH ( MAX ( 'Calendar'[Date] ) )
VAR CurrentYear =
YEAR ( TODAY () )
VAR DataYear =
YEAR ( MAX ( 'Calendar'[Date] ) )
RETURN
SWITCH (
TRUE (),
HASONEVALUE ( 'Calendar'[MONTH-YEAR] ),
IF (
DataYear > CurrentYear
|| ( DataYear = CurrentYear
&& DataMonth > CurrentMonth ),
MTD_SALES,
BLANK ()
),
[GSII LY]
)
If this works, please accept as the solution for others with the same challenge - it helps with visibility.
Hi,
Thanks for the input. It does this to my visual, which isn't what i'm looking for, unfortunately.
@Jæver - Sorry that's my bad, I got the IF results the wrong way around. This should work:
GS II MTD LY =
VAR MTD_SALES =
CALCULATE (
[Gross Sales II BC],
SAMEPERIODLASTYEAR (
DATESBETWEEN (
'Calendar'[Date],
STARTOFMONTH ( 'Calendar'[Date] ),
TODAY () - 1
)
)
)
VAR CurrentMonth =
MONTH ( TODAY () )
VAR DataMonth =
MONTH ( MAX ( 'Calendar'[Date] ) )
VAR CurrentYear =
YEAR ( TODAY () )
VAR DataYear =
YEAR ( MAX ( 'Calendar'[Date] ) )
RETURN
SWITCH (
TRUE (),
HASONEVALUE ( 'Calendar'[MONTH-YEAR] ),
IF (
DataYear > CurrentYear
|| ( DataYear = CurrentYear
&& DataMonth > CurrentMonth ),
BLANK (),
MTD_SALES
),
[GSII LY]
)
Thanks for the reply! This gives me the full LY numbers, which is close to what i'm aiming towards. As you can see, the FYTD (MTD LY) totals the same as the entire LY. The MTD LY column should total around 10 mio. LESS than the full last year (11.8 - 0.8). Is there any way to work around that?
@Jæver - It occured to me what you are trying to acheive this morning, so I have updated my earlier solution below.
This one should minus the current Month to date ONLY off of the LY total.
VAR MTD_SALES =
CALCULATE (
[Gross Sales II BC],
SAMEPERIODLASTYEAR (
DATESBETWEEN (
'Calendar'[Date],
STARTOFMONTH ( 'Calendar'[Date] ),
TODAY () - 1
)
)
)
VAR CurrentMonth =
MONTH ( TODAY () )
VAR DataMonth =
MONTH ( MAX ( 'Calendar'[Date] ) )
VAR CurrentYear =
YEAR ( TODAY () )
VAR DataYear =
YEAR ( MAX ( 'Calendar'[Date] ) )
VAR MTD_SALES_NOW =
CALCULATE (
MTD_SALES,
'Calendar'[Month_Number] = CurrentMonth
&& 'Calendar'[Year_Number] = CurrentYear
)
RETURN
SWITCH (
TRUE (),
HASONEVALUE ( 'Calendar'[MONTH-YEAR] ),
IF (
DataYear > CurrentYear
|| ( DataYear = CurrentYear
&& DataMonth > CurrentMonth ),
BLANK (),
MTD_SALES
),
[GSII LY] - MTD_SALES_NOW
)
If this works for you, please consider marking it as the solution.
@Jæver - Sorry it's no longer clear what result you require, are you trying to subtract the current MTD LY from the total of that Month LY?
If yes, you require this:
GS II MTD LY =
VAR MTD_SALES =
CALCULATE (
[Gross Sales II BC],
SAMEPERIODLASTYEAR (
DATESBETWEEN (
'Calendar'[Date],
STARTOFMONTH ( 'Calendar'[Date] ),
TODAY () - 1
)
)
)
VAR CurrentMonth =
MONTH ( TODAY () )
VAR DataMonth =
MONTH ( MAX ( 'Calendar'[Date] ) )
VAR CurrentYear =
YEAR ( TODAY () )
VAR DataYear =
YEAR ( MAX ( 'Calendar'[Date] ) )
RETURN
SWITCH (
TRUE (),
HASONEVALUE ( 'Calendar'[MONTH-YEAR] ),
IF (
DataYear > CurrentYear
|| ( DataYear = CurrentYear
&& DataMonth > CurrentMonth ),
BLANK (),
[GSII LY] - MTD_SALES
),
[GSII LY]
)
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
24 | |
22 | |
20 | |
15 | |
10 |