Forum Discussion

dofrancis3's avatar
dofrancis3
Icon for Resolver I rankResolver I
2 years ago
Solved

Display Previosly value date

Dear Colleagues could you help me with DAX Mesure!

As per the table below, i would like to disply separtly "Current" and "Previously" percentage of each country

 

Exemple for CD %
% Previously date60%
% Max date:100%

 

Country       Date       %

CD05/02/202395%
MU11/07/202322%
CD18/12/202360%
CD23/02/2024100%
MU02/05/202417%
  • Anonymous's avatar
    Anonymous
    2 years ago

    Your solution is great sanalytics , Allow me to offer another insight:

    Hi, dofrancis3 

    Based on your description, I used the following sample data:

    To make it more realistic for you, I've created a measure using a percentage column.

    I created two measures using the following two DAX expressions.

    Current Percentage = 
    VAR MaxDate = CALCULATE ( MAX ( 'Table'[Date]), ALLEXCEPT('Table','Table'[Country] ))
    RETURN
    CALCULATE (
        [PercentageMeasure],
        'Table'[Date] = MaxDate
    )
    Previous Percentage = 
    VAR MaxDate = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT('Table','Table'[Country] ))
    VAR PrevDate = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT('Table','Table'[Country] ), 'Table'[Date] < MaxDate )
    RETURN
    CALCULATE (
        [PercentageMeasure],
        'Table'[Date] = PrevDate
    )

    Here are the results:

     

    I've provided the PBIX file used this time below.

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

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

3 Replies

  • dofrancis3 

     

    You can try below measure

    Previous Value = 
     CALCULATE(
         SUM( 'Table'[Perc] ),
         OFFSET(
            -1,
             SUMMARIZE( ALL( 'Table' ),'Table'[Country],'Table'[Date], 'Table'[MaxTag] ),
             ORDERBY( 'Table'[Date], ASC ),PARTITIONBY('Table'[Country] )
         ) )

     

    Hope it helps.

     

    Regards

    sanalytics

    • dofrancis3's avatar
      dofrancis3
      Icon for Resolver I rankResolver I

      Dear sanalytics thank you for your suport !

      But please how can i do in case the % column is a Mesure? 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Your solution is great sanalytics , Allow me to offer another insight:

    Hi, dofrancis3 

    Based on your description, I used the following sample data:

    To make it more realistic for you, I've created a measure using a percentage column.

    I created two measures using the following two DAX expressions.

    Current Percentage = 
    VAR MaxDate = CALCULATE ( MAX ( 'Table'[Date]), ALLEXCEPT('Table','Table'[Country] ))
    RETURN
    CALCULATE (
        [PercentageMeasure],
        'Table'[Date] = MaxDate
    )
    Previous Percentage = 
    VAR MaxDate = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT('Table','Table'[Country] ))
    VAR PrevDate = CALCULATE ( MAX ( 'Table'[Date] ), ALLEXCEPT('Table','Table'[Country] ), 'Table'[Date] < MaxDate )
    RETURN
    CALCULATE (
        [PercentageMeasure],
        'Table'[Date] = PrevDate
    )

    Here are the results:

     

    I've provided the PBIX file used this time below.

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

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