Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello,
I'm trying to compare Last Month's Total Value against This Month's Total Value in a Clustered Column Chart.
please suggest an easy way to do this. following are the two columns I'm trying to get this done with.
Expense Date "dates in dd/mm/yyyy format"
Amount "value of expense"
Any help would be really appreciated.
Solved! Go to Solution.
So you could create a column like:
Month Legend =
VAR __Today = TODAY()
VAR __ThisMonthMin = DATE(YEAR(__Today),MONTH(__Today),1)
VAR __ThisMonthMax = EOMONTH(__Today,0)
VAR __LastMonthMax = EOMONTH(__Today,-1)
VAR __LastMonthMin = DATE(YEAR(__LastMonthMax),MONTH(__LastMonthMax),1)
RETURN
SWITCH(TRUE(),
[Expense Date] >= __ThisMonthMin && [Expense Date] <= __ThisMonthMax,"This Month",
[Expense Date] >= __LastMonthMin && [Expense Date] <= __LastMonthMax,"Last Month",
BLANK()
)
Then you could use that in your legend.
So you could create a column like:
Month Legend =
VAR __Today = TODAY()
VAR __ThisMonthMin = DATE(YEAR(__Today),MONTH(__Today),1)
VAR __ThisMonthMax = EOMONTH(__Today,0)
VAR __LastMonthMax = EOMONTH(__Today,-1)
VAR __LastMonthMin = DATE(YEAR(__LastMonthMax),MONTH(__LastMonthMax),1)
RETURN
SWITCH(TRUE(),
[Expense Date] >= __ThisMonthMin && [Expense Date] <= __ThisMonthMax,"This Month",
[Expense Date] >= __LastMonthMin && [Expense Date] <= __LastMonthMax,"Last Month",
BLANK()
)
Then you could use that in your legend.
Dear Greg,
Thank you so much your solution worked wonderfully. Although i don't fully understand what is happening in that Formula just did as you instructed and it works.
also can you please also edit it for quarterly comparision? i would have done it if i understood it fully 🙂
Thank you again Greg for helping me out this quickly.
@Anonymous Quarters are more of a pain in my opinion. You would need a numeric "Quarter" column using QUARTER function. Assuiming that exists and is called Quarter I would then probably do something like this:
Quarter Legend =
VAR __Today = TODAY()
VAR __ThisYear = YEAR(__Today)
VAR __ThisQuarter = QUARTER(__Today)
VAR __ThisQuarterMin = MINX(FILTER('Table',YEAR([Expense Date]) = __ThisYear && QUARTER([Expense Date]) = __ThisQuarter),[Expense Date])
VAR __ThisQuarterMax = MAXX(FILTER('Table',YEAR([Expense Date]) = __ThisYear && QUARTER([Expense Date]) = __ThisQuarter),[Expense Date])
VAR __LastQuarter =
SWITCH(__ThisQuarter,
1,4,
2,1,
3,2,
3
)
VAR __LastQuarterYear = IF(__ThisQuarter <> 4,__ThisYear,__ThisYear - 1)
VAR __LastQuarterMin = MINX(FILTER('Table',YEAR([Expense Date]) = __LastQuarterYear && QUARTER([Expense Date]) = __LastQuarter),[Expense Date])
VAR __LastQuarterMax = MAXX(FILTER('Table',YEAR([Expense Date]) = __LastQuarterYear && QUARTER([Expense Date]) = __LastQuarter),[Expense Date])
RETURN
SWITCH(TRUE(),
[Expense Date] >= __ThisQuarterMin && [Expense Date] <= __ThisQuarterMax,"This Quarter",
[Expense Date] >= __LastQuarterMin && [Expense Date] <= __LastQuarterMax,"Last Quarter",
BLANK()
)
OK, so apparently you don't need a separate QUARTER column, I just implemented it dynamically within the measure.
Hey @Anonymous - Sorry, coming back up to speed on this, so you want to compare this month to the last four months? Is that correct?
Yes Greg, but thanks your explainations above i was able to do this my self. also after doing this i'm facing an issue where in any of the last months data 31st date is not showing. This is not that big of a issue but still couldnt figure our why this is happening also im using Sharepoint as my data source.
This is the DAX im using.
Your Solution for Quarterly Comparsion work wonders again 🙂
Thank you so much Greg and Kudos for for the Best Solution.
Sure, @Anonymous let me explain what is going on:
User | Count |
---|---|
50 | |
23 | |
18 | |
18 | |
14 |
User | Count |
---|---|
91 | |
85 | |
46 | |
28 | |
21 |