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
Syndicate_Admin
Administrator
Administrator

create measure with range to compare after performing a segmentation

Hi

I need create measure with range 2 to compare targeting selection or some other solution that allows me to compare the current evaluation with the previous one, given a previous segment of year.

Tables

TB_EVALUATION_HISTORY

ID_checkGroup

ID_pHistory

ID_parent

ID_current_Assessment

Period

RANK

EVALUATIONS

check_11170202213_LOW
check_32135201922_MEDIUM
check_13263202211_HIGH
check_24237202123_LOW
check_1.95220202032_MEDIUM
check_1.96340202032_MEDIUM
check_1.97543202011_HIGH
check_28345202121_HIGH
check_39341201933_LOW
check_11034920221

1_HIGH

Column detail
ID_checkGroupPlanning identification
ID_pHistorysequential
ID_parentid to review context
ID_current_AssessmentEValuation
PeriodPlan period
RANKcolumn calculation to identify sequencial evaluation, considering all records

TB_EVALUATIONS
ID_current_AssessmentEVALUATIONS
703_LOW
352_MEDIUM
631_HIGH
373_LOW
202_MEDIUM
402_MEDIUM
431_HIGH
452_MEDIUM
413_LOW
491_HIGH

when i click on the period (2022).

The graph shows me all the records that were evaluated in 2022. But I can't show the previous evaluation done on the same record.

Expected graph, click on 2022

PedroPablo_6-1669057628356.png

Expected graph, when i click on the period (2021).

PedroPablo_7-1669057686474.png

THANKS!!

1 ACCEPTED SOLUTION

Hi @PedroPablo ,

 

Since the two posts are the same issue, I helped you merge into one post.

Hope you don't mind.

Here's the soultion to return the previous evaluation(rank+1).

You can create the following measure. Still put it into the visual-level filter and set up show items when the value is 1.

Measure =
VAR _rank =
    CALCULATE (
        SUM ( 'TB_EVALUATION_HISTORY'[Rank] ),
        FILTER (
            ALLSELECTED ( 'TB_EVALUATION_HISTORY' ),
            [ID_parent] = MAX ( 'TB_EVALUATION_HISTORY'[ID_parent] )
                && [Period] = SELECTEDVALUE ( 'TBPeriod'[Period] )
        )
    )
RETURN
    IF (
        IF ( ISBLANK ( _rank ), BLANK (), _rank + 1 )
            = MAX ( 'TB_EVALUATION_HISTORY'[Rank] ),
        1
    )
v

19.png

 

 

Best Regards,

Stephen Tao

 

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

7 REPLIES 7
PedroPablo
Helper I
Helper I

I have sample file and it contains

Measure

  • A_currentEvaluation: obtain minimun rank of period selected

Table

  • TBHISTORUY: historical data with evaluation
  • TBPeriod: Years to selected

 

PedroPablo_0-1669735835676.png

 

To select the most recent evaluation I did this and it works fine.

 

 

 

 

A_currentEvaluation = 

VAR __Rank1= CALCULATETABLE(VALUES (TB_EVALUATION_HISTORY[RANK]), 
                FILTER(
                ALLSELECTED ( TB_EVALUATION_HISTORY ),
                [ID_parent] = MAX ( 'TB_EVALUATION_HISTORY'[ID_parent] )
                    && [Period] = SELECTEDVALUE ( 'TBPeriod'[Period] )
                    && TB_EVALUATION_HISTORY[RANK]= MIN(TB_EVALUATION_HISTORY[RANK])
                    )
                )

VAR __COUNT= COUNTROWS(__Rank1)

RETURN
__COUNT

 

 

 

 

 

Now I need help select the previous evaluation (yellow). 

 

PedroPablo_1-1669744120254.png

 

 

 

TB_EVALUATION_HISTORY

ID_checkGroupID_pHistoryID_parentID_current_AssessmentPeriodEVALUATIONSRANK
check_1117020223_LOW1
check_3213520192_MEDIUM2
check_1326320221_HIGH1
check_2423720213_LOW2
check_1.9522020202_MEDIUM3
check_1.9634120202_MEDIUM3
check_1.9754320201_HIGH1
check_2834520211_HIGH2
check_3934020193_LOW4
check_11034920221_HIGH1

 

TBPeriod

Period
2019
2020
2021
2022

 

 

código de rank (columna calculada) TB_EVALUATION_HISTORY

 

 

 

RANK = RANKX(FILTER(TB_EVALUATION_HISTORY,TB_EVALUATION_HISTORY[ID_parent]=EARLIER(TB_EVALUATION_HISTORY[ID_parent]))
        , TB_EVALUATION_HISTORY[ID_current_Assessment]
        ,
        ,DESC
        ,Dense)

 

 

 

 

pd: This is a reformulated questio from a previous one.

 

Syndicate_Admin
Administrator
Administrator

Hi man!!

Sorry for the response time.

It's not really the year+1. It is the previous evaluation, that is rank+1..

v-stephen-msft
Community Support
Community Support

Hi @PedroPablo ,

 

You want to filter out a year based on the slicer and then return the values of the filtered year and the previous year of the filtered year, right?

You may need a seperate year slicer. You could create a year table using DAX.

Table = DISTINCT('TB_EVALUATION_HISTORY'[Period])

vstephenmsft_0-1669083711755.png

 

Then create a measure as a visual level filter.

Measure =
VAR _year =
    MAX ( 'TB_EVALUATION_HISTORY'[Period] )
VAR _select =
    CALCULATE (
        MAX ( 'TB_EVALUATION_HISTORY'[Period] ),
        FILTER (
            ALLSELECTED ( TB_EVALUATION_HISTORY ),
            [ID_parent] = MAX ( 'TB_EVALUATION_HISTORY'[ID_parent] )
                && [Period] = SELECTEDVALUE ( 'Table'[Period] )
        )
    )
RETURN
    IF ( _select = _year || _select - 1 = _year, 1 )

Put the measure into the visual level filter of the table visual. Set up show items when the value is 1.

11.png

 

 

Best Regards,

Stephen Tao

 

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

Sorry for the response time.

 

It's not really the year+1. It is the previous evaluation, that is rank+1..

Hi @PedroPablo ,

 

Since the two posts are the same issue, I helped you merge into one post.

Hope you don't mind.

Here's the soultion to return the previous evaluation(rank+1).

You can create the following measure. Still put it into the visual-level filter and set up show items when the value is 1.

Measure =
VAR _rank =
    CALCULATE (
        SUM ( 'TB_EVALUATION_HISTORY'[Rank] ),
        FILTER (
            ALLSELECTED ( 'TB_EVALUATION_HISTORY' ),
            [ID_parent] = MAX ( 'TB_EVALUATION_HISTORY'[ID_parent] )
                && [Period] = SELECTEDVALUE ( 'TBPeriod'[Period] )
        )
    )
RETURN
    IF (
        IF ( ISBLANK ( _rank ), BLANK (), _rank + 1 )
            = MAX ( 'TB_EVALUATION_HISTORY'[Rank] ),
        1
    )
v

19.png

 

 

Best Regards,

Stephen Tao

 

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

@v-stephen-msft 

This effectly resolve the ticket, thanks!!

if it is possible, I need count register whit condition
 

Hi @PedroPablo ,

 

This is a brand new requirement, for this, it is recommended that you reopen a new post, thank you.😁

Glad to hear that my solution works.

 

 

Best Regards,

Stephen Tao

 

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

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.