Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ssingh_leecare
Frequent Visitor

Return an array of unique values in a measure/variable as a filter for further calculations

I wish to return an array or a list of unique "PersonIDs" in a measure/variable within a measure.

And then use it as a filter for another measure/variable to display the results for only those personID's who were there in previous case.

7 REPLIES 7
ssingh_leecare
Frequent Visitor

Hi @kunal15sep @Jihwan_Kim 
Thank you for your responses. I will explain the problem I have and what I am trying to achieve. These are the tables and connections I have right now.

ssingh_leecare_1-1667971832190.png

 

FirstFormSaves has first saves for different forms for every personID, with the dates the forms were saved. So, for every personID, there's only one Form save of a certain type. 
This is connected to date table.

Person has all the personIDs.

Status is the table with personIDs, their status and the dates. 

I am using a timeline slicer. Assuming start date is A and End Date is B, I wish to return:

Get those personIDs which had status "XYZ" between A and B from table Status (Or Person since it is a 2-way relation).
Once we have these personIDs, get the total of all forms saved till B (Ignore start date A) only for those personIDs who we got from the statement above.

The personIDs we need have to be with status XYZ only between A and B. Forms saved should be everything till B, for only these personIDs.

I hope this clears the doubts, let me know if you need anything else.
Thanks in advance!

Re: Return an array through a measure, and then us... - Microsoft Power BI Community
This was also posted by me and @amitchandak shared some insights, which may help.

Hi @amitchandak, this is a detailed explanation of what I am after.

Thanks in advance!

Jihwan_Kim
Super User
Super User

Hi,

I do not know how your datamodel looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

I hope the below sample can provide some ideas on how to create a solution for your datamodel.

 

 

Jihwan_Kim_1-1667970563265.png

 

 

Jihwan_Kim_0-1667970549553.png

 

September 2022 qty > 15 IDs total qty: =
VAR _condition =
    FILTER (
        ADDCOLUMNS (
            ALL ( PersonID[PersonID] ),
            "@sepQTY",
                CALCULATE (
                    SUM ( Sales[Quantity] ),
                    EOMONTH ( Sales[Date], 0 ) = DATE ( 2022, 9, 30 )
                )
        ),
        [@sepQTY] > 15
    )
VAR _list =
    SUMMARIZE ( _condition, PersonID[PersonID] )
RETURN
    CALCULATE (
        SUM ( Sales[Quantity] ),
        KEEPFILTERS ( PersonID[PersonID] IN _list )
    )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

kunal15sep
Frequent Visitor

You can use VALUES(<TableNameOrColumnName>) for array of unique values in a column

Hi @kunal15sep 
And how should I use that as a filter in the next statement, something like
var A = values(personID)
filter(personIDs IN A)

@ssingh_leecare , If what I understand to be your requirement, you may consider using calculated column to LOOKUPVALUE and return 1 or 0 comparing from the previous case table. Then filtering the table view to get aggregated measures.

In response to a calculated column, it has to be dynamic and change with the selection on date slicer, which won't be possible if I make a calculated column.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.