Index Match in Dax?

hayden

Board Regular
Joined
Sep 23, 2005
Messages
188
I have created a query from a csv file that results in a dataset named 'Daily Stats' that looks like this:

Screenshot 2023-12-01 140722.png


I've also created a measure to calculate the minimum of the 8ResContents attribute.

The result of that based on the table above would be 499. Now I am trying to create another measure to return the drought stage during this minimum storage.

In excel this would simply be an index and match.. But I haven't been able to figure out how to do this in DAX/PQ.

I'm pretty new at Dax, so if you have the time to help me understand what your solutions is dong that would be wonderful, but not required.
 

Attachments

  • 1701464887338.png
    1701464887338.png
    9.3 KB · Views: 20

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
This is actually quite tricky in DAX. I’m not at my pc so its hard for me to provide an exact solution.
in short, you need to
filter the table based on the min value
with that filter applied, extract the date
then apply the date filter back on the table to fetch the other number.

you could also pivot the data in PQ first. turn the attribute column into multiple columns If you put a bottomN filter on a visual, it would give the 499 value showing all the other data, too. But that wouldn’t allow you to do more calcs.
if you load a workbook with some sample data, I can take a look when I’m back at my pc.
 
Upvote 0
@Matt Allington - Thanks for the quick reply. Glad to know it wasn't something super simple that I was missing. I've sent you a private message with a dropbox link to the workbook. If you need the CSV file let me know. I'll read up on lookupvalue()...

I was trying that but it requires a specific column, not an attribute, and I don't think I can pass it a measure as the value to lookup.

But I'll keep looking.
 
Upvote 0
@Matt Allington - Thanks for the quick reply. Glad to know it wasn't something super simple that I was missing. I've sent you a private message with a dropbox link to the workbook. If you need the CSV file let me know. I'll read up on lookupvalue()...

I was trying that but it requires a specific column, not an attribute, and I don't think I can pass it a measure as the value to lookup.

But I'll keep looking.
You can definitely pass a measure as the value to look up
 
Upvote 0
I duplicated my query and left the data as a table (i.e, attribute as a column header, and a value for each date in each row). With this loaded to the datamodel I was able to use lookupvalue along with measures to get the values I needed.

Not thrilled about having to load my data twice (once as a table, and the same table unpivoted), but for now that will work.
 
Upvote 0
@Matt Allington - Thanks for the quick reply. Glad to know it wasn't something super simple that I was missing. I've sent you a private message with a dropbox link to the workbook. If you need the CSV file let me know. I'll read up on lookupvalue()...

I was trying that but it requires a specific column, not an attribute, and I don't think I can pass it a measure as the value to lookup.

But I'll keep looking.
I'm not sure if this is private data or not. I offer support that I can publish publicly so that others can benefit, too. I can't see any reason why you can't use the unpivoted data to do this. If you publicly post some data that I can use that is unpivoted, I will have a go for you.
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,108
Members
452,302
Latest member
TaMere

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