The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have the below table (new version) for my testing data.
How can I create a measure for a line chart to display the latest amount based on the category, date and month?
The reason why I need to filter by date and month is because there will be a month 13. Month 13 is an Audited Amount.
From there, I will filter the data to the latest 3 years. Below is the measure that I used. If anyone has the simplified version, please do advise me.
Last 3 Years =
VAR _currentyear = YEAR(TODAY())
VAR _previousyear = SELECTEDVALUE(test4_3years[Year])
RETURN
SWITCH(
TRUE(),
_previousyear <= _currentyear -1 &&
_previousyear >= _currentyear -3, 1,
0
)
Thank you.
Regards,
NickzNickz
Solved! Go to Solution.
Hi @NickzNickz ,
Try this measure.
Latest Amount =
VAR LatestDate =
CALCULATE (
MAX ( TableName[Date] ),
ALLEXCEPT ( TableName, TableName[Category] )
)
var _13=CALCULATE(SUM('TableName'[Amount]),FILTER(ALL('TableName'),'TableName'[Date]=MAX('TableName'[Date]) && 'TableName'[Category]=MAX('TableName'[Category]) && 'TableName'[Month]=13))
var _amount=
CALCULATE (
SUM ( TableName[Amount] ),
TableName[Date] = LatestDate
)
return IF(_13 =BLANK(),_amount,_13)
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @NickzNickz ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a measure.
Latest Amount =
VAR LatestDate =
CALCULATE (
MAX ( TableName[Date] ),
ALLEXCEPT ( TableName, TableName[Category] )
)
RETURN
CALCULATE (
SUM ( TableName[Amount] ),
TableName[Date] = LatestDate
)
Last 3 Years =
VAR _currentyear = YEAR(TODAY())
VAR _previousyear = SELECTEDVALUE(test4_3years[Year])
RETURN
IF ( _previousyear <= _currentyear - 1 && _previousyear >= _currentyear - 3, 1, 0 )
(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
I have tested to view the result...
Based on the scenario, if the category has month 12 and month 13, the measure should pick up month 13 only or else month 12 ...
Regards,
NickzNickz
Hi @NickzNickz ,
Try this measure.
Latest Amount =
VAR LatestDate =
CALCULATE (
MAX ( TableName[Date] ),
ALLEXCEPT ( TableName, TableName[Category] )
)
var _13=CALCULATE(SUM('TableName'[Amount]),FILTER(ALL('TableName'),'TableName'[Date]=MAX('TableName'[Date]) && 'TableName'[Category]=MAX('TableName'[Category]) && 'TableName'[Month]=13))
var _amount=
CALCULATE (
SUM ( TableName[Amount] ),
TableName[Date] = LatestDate
)
return IF(_13 =BLANK(),_amount,_13)
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
User | Count |
---|---|
15 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
23 | |
14 | |
13 | |
8 | |
8 |