I've got an histogram with MeasureA=SUM([ValueA]) by Year and Month based on fields on TableA.
I've got TableB with field [ValueB] and MeasureB=SUM([ValueB]).
I would like to create a MeasureC=MeasureA+MeasureB where MeasureB adds its value on the histogram only on current year bar or current year and current month.
Is it possible?
Thanks in advance
Go to Solution.
Based on your description, I created data to reproduce your scenario.
You may create measures as follows.
MeasureA = SUM('Table A'[ValueA])
MeasureB = SUM('Table B'[ValueB])
var _currentmonth = MONTH(TODAY())
var _currentyear = YEAR(TODAY())
var _date = MAX('Table A'[Date])
MONTH(_date) = _currentmonth&&YEAR(_date)=_currentyear,
'Table A'[Date].[MonthNo] = _currentmonth&&'Table A'[Date].[Year]=_currentyear
'Table B'[Date].[MonthNo] = _currentmonth&&'Table B'[Date].[Year]=_currentyear
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
View solution in original post
Well yes but that really depends on your datastructure to have an exact answer. It will be somewhere along the lines of this:
VAR _curSelectedYear = YEAR(MAX(Table[Date]))
VAR _curSelectedMonth = MONTH(MAX(Table[Date]))
VAR _currentYear = YEAR(TODAY())
VAR _currentMonth = MONTH(TODAY())
VAR _toAdd = IF(_curSelectedYear = _currentYear && _curSelectedMonth = _currentMonth, [MeasureB], 0)
[MeasureA] + _toAdd
SOmething like this?
If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.
Keep those thumbs up coming! 🙂
Proud to be a Super User!
Take a look at the September 2023 Power BI update to learn more.
Join Microsoft Reactor and learn from developers.