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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.