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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ldmass
Regular Visitor

Get last sequences for a value

Hi Experts,
I'm having trouble solving an issue that seems simple but I can't find the solution. I have a table where I have the following columns:

 

SinisterSequenceDatePatientEpisodeType of Coverage
1000101-01-2022Juan12
1000205-01-2022Juan24
1000302-02-2022Juan31
1000415-02-2022Juan44
1001102-02-2022Pedro14
1001215-01-2022Pedro42
1001302-02-2022Pedro54
1000501-03-2022Juan48

I need for a range of dates to show the last Sequence (Column B) for the same Sinister (Column A), and then filter by Type of Coverage (Column F). For example:
Example 1:
If in the date slicer I select 01-01-2022 to 01-31-2022, only row 4 should be displayed in the matrix/table. Why?
- For Sinister 1000, the last sequence is 2 and type of coverage is 4
- For Sinister 1001, the last sequence is 2 but the Type of Coverage is 2.


Example 2:
If in the date slicer I select 01-01-2022 to 28-02-2022, only row 5 and 8 should be displayed in the matrix/table. Why?
- For Sinister 1000, the last sequence is 4 and type of coverage is 4.
- For Sinister 1001, the last sequence is 3 and type of coverage is 4.

 

Any help is welcome.

 

Greetings,

LM

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @ldmass ,

Here are the steps you can follow:

1. Create calculated table.

Date =
CALENDAR( DATE(2022,1,1),DATE(2022,12,31))

vyangliumsft_0-1668562676878.png

2. Create measure.

Flag =
var _mindate=MINX(ALLSELECTED('Date'),[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),[Date])
var _max=
MAXX(FILTER(ALLSELECTED('Table'),
'Table'[Date]>=_mindate&&'Table'[Date]<=_maxdate&&'Table'[Sinister]=MAX('Table'[Sinister])),[Sequence])
return
IF(
    MAX('Table'[Sequence])=_max,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1668562676881.png

4. Result:

vyangliumsft_2-1668562676885.png

 

Best Regards,

Liu Yang

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

View solution in original post

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @ldmass ,

Here are the steps you can follow:

1. Create calculated table.

Date =
CALENDAR( DATE(2022,1,1),DATE(2022,12,31))

vyangliumsft_0-1668562676878.png

2. Create measure.

Flag =
var _mindate=MINX(ALLSELECTED('Date'),[Date])
var _maxdate=MAXX(ALLSELECTED('Date'),[Date])
var _max=
MAXX(FILTER(ALLSELECTED('Table'),
'Table'[Date]>=_mindate&&'Table'[Date]<=_maxdate&&'Table'[Sinister]=MAX('Table'[Sinister])),[Sequence])
return
IF(
    MAX('Table'[Sequence])=_max,1,0)

3. Place [Flag]in Filters, set is=1, apply filter.

vyangliumsft_1-1668562676881.png

4. Result:

vyangliumsft_2-1668562676885.png

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors