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
jiangchuan23
Frequent Visitor

How Can I create a measure which is the reverse of another measure

 

 

I have a measure created by as following:

 

cumulative good=CALCULATE(sum(table[good]),FILTER(ALLSELECTED(table),table[Custom Score Gains (bins)] <= max(table[Custom Score Gains (bins)])))

 

Herer is table:

 

 

fffff.PNG

 

I would like to create a new measure which is the reserve order of measure cumulative good. So it will start value 345768 at frist bin 387. Then the second bin value will be 345118. ............................ and the last bin value would be 2. How I can I create such measure ?

 

Thanks,

 

1 ACCEPTED SOLUTION

 

 

I get it working .Thanks guys

@Zubair_Muhammad

@Vvelarde 

 

Cumulative good(cbr)2 = CALCULATE(sum(tracking_data_combined2[good]),FILTER(ALLSELECTED(tracking_data_combined2),tracking_data_combined2[FICO_BIN] <= MAX(tracking_data_combined2[FICO_BIN])))

 

measure 3 =
Var RANK_desc =
RANKX (
    ALLSELECTED ( table[FICO_BIN] ),
    [Cumulative good(cbr)1],
    ,
   DESC
)
return
CALCULATE(sum(table[good]),TOPN (RANK_desc, SUMMARIZE(ALLSELECTED( table),table[FICO_BIN],"total good",sum(table[good]))table[FICO_BIN],ASC))

 

 

111.PNG

 

View solution in original post

11 REPLIES 11
Vvelarde
Community Champion
Community Champion

@jiangchuan23

 

Hi, please try with this: **Adapt the measure to your scenario.

 

Measure =
VAR Category =
    SELECTEDVALUE ( Table1[Category] )
VAR CategoriesTotal =
    CALCULATE ( DISTINCTCOUNT ( Table1[Category] ); ALL ( Table1 ) )
VAR Categoriesbefore =
    CALCULATE (
        DISTINCTCOUNT ( Table1[Category] );
        FILTER ( ALL ( Table1 ); Table1[Category] < Category )
    )
VAR CategoriesAfter = CategoriesTotal - Categoriesbefore
RETURN
    CALCULATE (
        SUM ( Table1[Value] );
        TOPN ( CategoriesAfter; ALL ( Table1 ); Table1[Category]; ASC )
    )

 

 

ReImg1.pnggards

 

Victor




Lima - Peru

THanks Victor. I tried your solution but still can't get it to work. Do you know why ?

 

Measure =
VAR Category =
SELECTEDVALUE ( tracking_data_combined2[FICO_BIN] )
VAR CategoriesTotal =
CALCULATE ( DISTINCTCOUNT ( tracking_data_combined2[FICO_BIN] ), ALLSELECTED(tracking_data_combined2 ) )
VAR Categoriesbefore =
CALCULATE (
DISTINCTCOUNT ( tracking_data_combined2[FICO_BIN] ),
FILTER ( ALLSELECTED( tracking_data_combined2 ), tracking_data_combined2[FICO_BIN]<Category) )
VAR CategoriesAfter = CategoriesTotal - Categoriesbefore
RETURN
CALCULATE (
SUM ( tracking_data_combined2[good]),
TOPN ( CategoriesAfter, ALLSELECTED( tracking_data_combined2),tracking_data_combined2[FICO_BIN], asc)
)

 111.PNG

jiangchuan23
Frequent Visitor

Anyone knew how to create such measure ?

Maybe cumulative good2=SUM(table[good])-CALCULATE(sum(table[good]),FILTER(ALLSELECTED(table),table[Custom Score Gains (bins)] <= max(table[Custom Score Gains (bins)])))

Thanks for your reply. Not really working 

 

111.PNG

@jiangchuan23

 

I am not sure. But give it a shot.

 

First create these RANK MEASURES

 

RANK Asc =
RANKX (
    ALLSELECTED ( 'Table'[Custom Score Gains (bins)] ),
    [cumulative good],
    ,
    ASC
)
RANK Desc =
RANKX (
    ALLSELECTED ( 'Table'[Custom Score Gains (bins)] ),
    [cumulative good],
    ,
    DESC
)

Regards
Zubair

Please try my custom visuals

@jiangchuan23

 

Using the above RANK measures... you might get the good column in reverse order using this MEASURE

 

Reverse good =
VAR myrank = [RANK Asc]
RETURN
    CALCULATE (
        SUM ( 'Table'[good] ),
        FILTER (
            ALLSELECTED ( 'Table'[Custom Score Gains (bins)] ),
            [RANK Desc] = myrank
        )
    )

Then you can cumulate this ReverseGood measure


Regards
Zubair

Please try my custom visuals

@Zubair_Muhammad

 

Muhammad, Do you know how to do cumulative for the measure ReverseGood ?

@jiangchuan23

 

Could you share your file?

 

I will look into it


Regards
Zubair

Please try my custom visuals

 

 

I get it working .Thanks guys

@Zubair_Muhammad

@Vvelarde 

 

Cumulative good(cbr)2 = CALCULATE(sum(tracking_data_combined2[good]),FILTER(ALLSELECTED(tracking_data_combined2),tracking_data_combined2[FICO_BIN] <= MAX(tracking_data_combined2[FICO_BIN])))

 

measure 3 =
Var RANK_desc =
RANKX (
    ALLSELECTED ( table[FICO_BIN] ),
    [Cumulative good(cbr)1],
    ,
   DESC
)
return
CALCULATE(sum(table[good]),TOPN (RANK_desc, SUMMARIZE(ALLSELECTED( table),table[FICO_BIN],"total good",sum(table[good]))table[FICO_BIN],ASC))

 

 

111.PNG

 

Thanks for your reply Muhammad. 

 

Here is the snapshot after I implemented your code. In my data, there is a few bins Dont have any obs in it 

 

111.PNG

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.