Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Create a column with value from calculated column for prior quarter

I'm relatively new to Power BI and I'm struggling to figure out the appropriate DAX formula to achieve the following:

 

I want to create a column that retrieves the prior quarter's value for a measure called "% of Target" so that I have a column for the current quarter's % of target and a column for the prior quarter's % of target.  My table has 100's of items that show values for 12 quarters so I want to use the values in the columns at the row-level in my reports.

 

The table below shows the last column, which is the one I wanted to generate.

 

TitleTargetProgressUnitPeriod End% of TargetPrior Qtr - % of Target
Associate engagement score81.081.0unit3/31/2021100% 
Associate engagement score8182unit6/30/2021101%100%
Cloud Training Certifications100.098.0%3/31/202198%101%
Cloud Training Certifications10094%6/30/202194%98%
Expense56231.042000.0$3/31/202175%94%
Expense $          96,532 $       94,545$6/30/202198%75%
Interlock Revenue Attainment100.0100.0%3/31/2021100%98%
Interlock Revenue Attainment10090%6/30/202190%100%
Net Promoter Score (NPS)59.057.0unit3/31/202197%90%
Net Promoter Score (NPS)6061unit6/30/2021102%97%
New Logos3.01.0unit3/31/202133%102%
New Logos54unit6/30/202180%33%
On-time Solution Implementation100.0100.0%3/31/2021100%80%
On-time Solution Implementation10095%6/30/202195%100%
Product Quality – Avg # Issues8.86.0unit3/31/202168%95%
Product Quality – Avg # Issues8.48.4unit6/30/2021100%68%
Product Quality – R&D Completion82.082.0%3/31/2021100%100%
Product Quality – R&D Completion8482%6/30/202198%100%
Product Quality – UDL Clean Run96.096.0%3/31/2021100%98%
Product Quality – UDL Clean Run9696%6/30/2021100%100%
Revenue92112.0920444.0$3/31/2021999%100%
Revenue $          90,223 $6/30/20210%999%
Solution Roadmap On-time completion100.0100.0%3/31/2021100%0%
Solution Roadmap On-time completion10088%6/30/202188%100%

 

 

  • Hi Anonymous 

    You can create a Calculated column as the following.

     

    Prior Qtr - % of Target =
    
    VAR cloest_title =
    
        MAXX (
    
            FILTER ( 'Table', 'Table'[Title] < EARLIER ( 'Table'[Title] ) ),
    
            'Table'[Title]
    
        )
    
    VAR _min =
    
        MAXX (
    
            FILTER (
    
                'Table',
    
                'Table'[Title] = EARLIER ( 'Table'[Title] )
    
                    && 'Table'[Period End] < EARLIER ( 'Table'[Period End] )
    
                    || 'Table'[Title] = cloest_title
    
                        && 'Table'[Period End] > EARLIER ( 'Table'[Period End] )
    
            ),
    
            [% of Target]
    
        )
    
    RETURN
    
        _min

     

    The result looks like this:

     

    For more details, you can refer the attached pbix file.

     

    Best Regards

    Caiyun Zheng

     

    If this post helps, please consider make it as the solution by Accept it as Solution. Really appreciate!

2 Replies

  • Anonymous , Try a new column like

     

    New column =
    var _min = maxx(filter(Table, [Period end] <earlier([period end])),[period end])
    return
    maxx(filter(Table, [Period end] = _min),[% of Target])

  • v-cazheng-msft's avatar
    v-cazheng-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous 

    You can create a Calculated column as the following.

     

    Prior Qtr - % of Target =
    
    VAR cloest_title =
    
        MAXX (
    
            FILTER ( 'Table', 'Table'[Title] < EARLIER ( 'Table'[Title] ) ),
    
            'Table'[Title]
    
        )
    
    VAR _min =
    
        MAXX (
    
            FILTER (
    
                'Table',
    
                'Table'[Title] = EARLIER ( 'Table'[Title] )
    
                    && 'Table'[Period End] < EARLIER ( 'Table'[Period End] )
    
                    || 'Table'[Title] = cloest_title
    
                        && 'Table'[Period End] > EARLIER ( 'Table'[Period End] )
    
            ),
    
            [% of Target]
    
        )
    
    RETURN
    
        _min

     

    The result looks like this:

     

    For more details, you can refer the attached pbix file.

     

    Best Regards

    Caiyun Zheng

     

    If this post helps, please consider make it as the solution by Accept it as Solution. Really appreciate!