How to extract a specific row's value in DAX?

cr731

Well-known Member
Joined
Sep 17, 2010
Messages
611
I have a table in my data model that looks something like this,

[table="width: 500, class: grid"]
[tr]
[td]Item[/td]
[td]Contents[/td]
[/tr]
[tr]
[td]Current Month[/td]
[td]Jan 2016[/td]
[/tr]
[tr]
[td]Prior Month[/td]
[td]Dec 2015[/td]
[/tr]
[/table]

And then I have another table with a listing of transactions by date (just by month, not specific to the day).

I want to create a calculated measure summing all transactions in the "Current Month" as it exists in my table shown above. So I am trying to somehow extract the "Current Month" line from that table, and use it in a calculated measure, but having no luck. I tried this,

=CALCULATE( DATEVALUE([Contents], FILTER( TableContents, TableContents[Item] = "Current Month") )

But this doesn't seem to work.

Any advice on how to resolve this or a better approach?

Thanks
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
firstly I am not sure that this is the best way to have your data, but then again I don't know what you are trying to do.

I think the issue is that DATEVALUE expects a value, but you are passing a column. Try this

=CALCULATE( DATEVALUE(values([Contents]), FILTER( TableContents, TableContents[Item] = "Current Month") )

You may need to wrap part of the formula in an HASONEVALUE test, I'm not sure. If so, you could try this, but I don't know if it will work.

=CALCULATE( if(HASONEVALUE(tablecontents[item]), DATEVALUE(values([Contents])), FILTER( TableContents, TableContents[Item] = "Current Month") )
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,151
Messages
6,176,717
Members
452,740
Latest member
MrCY

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top