cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ING_BT
Helper I
Helper I

Cohort - Calculation Troubles - Calculate / Divide and MIN ?

Hello All, 

 

I'm using the Matrix visual in Power BI to create a "Cohort" analysis. 

 

As you can see below, we have the date month of the first order (first column) and then by month how many customers stayed. 

The table is build in a was that we have no date intelligence. Thus I'm solely relying on min/max (but it doesn't work). 

 

In the expected result table, you can see that I want to :
Divide(
Calculate(sum(value)),
Calculate(sum(value)),
Filtered by ? To obtain the minimum of the row.

 

Exemple: 80/150=53% for 201704 on the row 201701

 

Screenshot_2.png

the "201701" are number and represent the year & month. 

 

Thank you in advance for your insights! 

 

Best,

BT

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

Hi @ING_BT , 

Please refer to my pbix file to see if it helps you.

Craete a measure.

Measure =
VAR _mindate =
    CALCULATE (
        MIN ( 'Table'[date 2] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] = SELECTEDVALUE ( 'Table'[date] )
                && 'Table'[value] <> BLANK ()
        )
    )
VAR mu_ =
    CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] = SELECTEDVALUE ( 'Table'[date] )
                && 'Table'[date 2] = _mindate
        )
    )
VAR zi =
    MAX ( 'Table'[value] )
RETURN
    DIVIDE ( zi, mu_ )

vpollymsft_0-1649647533241.png

If I have misunderstood your meaning, please provide your pbix file without privacy information.

 

Best Regards

Community Support Team _ Polly

 

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

2 REPLIES 2
ING_BT
Helper I
Helper I

Hello Polly, 

 

Thank you for your solution, it helps on the information I've provided ! 
Unfortunatly, my data set is quite differente with several dimensions&filters; so I'm working on modifiying this first and adapte your approach. 

 

Thank you for your help!

 

Best,

BT

 

v-polly-msft
Community Support
Community Support

Hi @ING_BT , 

Please refer to my pbix file to see if it helps you.

Craete a measure.

Measure =
VAR _mindate =
    CALCULATE (
        MIN ( 'Table'[date 2] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] = SELECTEDVALUE ( 'Table'[date] )
                && 'Table'[value] <> BLANK ()
        )
    )
VAR mu_ =
    CALCULATE (
        MAX ( 'Table'[value] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] = SELECTEDVALUE ( 'Table'[date] )
                && 'Table'[date 2] = _mindate
        )
    )
VAR zi =
    MAX ( 'Table'[value] )
RETURN
    DIVIDE ( zi, mu_ )

vpollymsft_0-1649647533241.png

If I have misunderstood your meaning, please provide your pbix file without privacy information.

 

Best Regards

Community Support Team _ Polly

 

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

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors