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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Select a Unique Row from a Group with Master Sequence and Count the Rows

H Everyone, Question on Filter Sequence Based Max value

 

This is how my table Looks currently 

 

 

Policy Master Policy Number Sequence
1234uwWCE21441
1234uwWC233332
1234uwWCE2223134
1234uw12ERRRR3
21ECRC23ECRT1
2123452C34442

 

So from the set above i would need to find the Policy Number Associate with each set of Policy Master based on Max of Sequence . 

 

Then i would have to do a count of all such policies. 

 

Appreciate if anyone could help on this quick.

 

 

 

 

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @Anonymous 

 

Based on your description, I created data to reproduce your scenario.

Table:

c1.png

 

You may two measures as below.

 

Count = 
var _policymaster = SELECTEDVALUE('Table'[Policy Master ])
return
CALCULATE(
    DISTINCTCOUNT('Table'[Policy Number ]),
    FILTER(
        ALLSELECTED('Table'),
        'Table'[Policy Master ]=_policymaster&&
        'Table'[Sequence]=
        CALCULATE(
            MAX('Table'[Sequence]),
            FILTER(
                ALLSELECTED('Table'),
                'Table'[Policy Master ]=_policymaster
            )
        )
    )
)

CountTotal = 
SUMX(
    SUMMARIZE(
        'Table',
        'Table'[Policy Master ],
        "Count",
        var x = 'Table'[Policy Master ]
        return
        CALCULATE(
                DISTINCTCOUNT('Table'[Policy Number ]),
                FILTER(
                    ALLSELECTED('Table'),
                    'Table'[Policy Master ]=x&&
                    'Table'[Sequence]=
                    CALCULATE(
                        MAX('Table'[Sequence]),
                        FILTER(
                            ALLSELECTED('Table'),
                            'Table'[Policy Master ]=x
                        )
                    )
                )
        )
    ),
    [Count]
)

 

 

Result:

c2.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Pragati11
Super User
Super User

Hi @Anonymous ,

 

You can create two calculated columns as follows:

max Seq = CALCULATE(MAX('policy Data'[Sequence]), FILTER(ALLSELECTED('policy Data'), 'policy Data'[PolicyMaster] = EARLIER('policy Data'[PolicyMaster])))
 
PolicyOnMaxSeq = CALCULATE(MAX('policy Data'[Policy Number]), FILTER(ALLSELECTED('policy Data'), 'policy Data'[max Seq] = EARLIER('policy Data'[max Seq]) && 'policy Data'[PolicyMaster] = EARLIER('policy Data'[PolicyMaster])))
 
I used the sample data from your screenshot and I get the following result:
p1.png
If this helps and resolves the issue, appreciate a Kudos and mark it as a Solution! 🙂
 
Thanks,
Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Anonymous 

create a desc rank policy master sequence and filter on 1

For Rank Refer these links

https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale

 

The file is created after the signature. Created as column

Anonymous
Not applicable

@amitchandak Thanks for the quick response,

 

while it did answer on how i can pull a unique row from the Rank Function.

 

I'm still not sure on how to take a count of  Policy number (Policy Number from my example table )  from the derived unique row for the output of Rank function.

Hi @Anonymous ,

 

Can you check my response if that helps you?

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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