Forum Discussion
Add Measure to Table, filtering Text column by the Year column.
Hello, I'm very new to Power BI, so hopefully this question makes sense.
I have a table in my data model that lists 'risk assesment' text by year for each project.
eg
Year: 2021, Risk Assessment: Medium
Year: 2022, Risk Assessment: High
How do I create a DAX measure that returns 'Medium' for the year 2021 in the Table visual I've created?
- Anonymous5 years ago
Hello amitchandak, thank you for your reply, after a lot of trial and error, the following worked:
Spend Risk Assessment CY = CALCULATE(SELECTEDVALUE('Spend Annual Data'[Spend Risk Assessment]),'Spend Annual Data'[Year Number]=YEAR(TODAY()))
I'm not sure why SELECTEDVALUE was necessary. Thank you for directing me towards the correct answer.
3 Replies
- amitchandakSuper User
Anonymous , Create a measure like
Calculate(Table[Risk Assessment], filter(Table, Table[Year] =2021))
- AnonymousNot applicable
Hello amitchandak, thank you for your reply, after a lot of trial and error, the following worked:
Spend Risk Assessment CY = CALCULATE(SELECTEDVALUE('Spend Annual Data'[Spend Risk Assessment]),'Spend Annual Data'[Year Number]=YEAR(TODAY()))
I'm not sure why SELECTEDVALUE was necessary. Thank you for directing me towards the correct answer.- IceyCommunity Support
Hi Anonymous ,
You can also use MAX, MIN, FIRSTNONBLANK, etc, to return the value filtered by the current context.
For context, please refer to this document:
DAX basics in Power BI Desktop - Power BI | Microsoft Docs.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.