Forum Discussion

JimSales81's avatar
JimSales81
Helper I
1 year ago
Solved

Compare Dynamic Columns in a Matrix

My Users like to see Quarter over Quarter sales so i've created a measure for each quarter's sales going back to Q1/2024 and added to a matrix. Some like to see $ change and % change from previous quarter while some like to see $ Change and % Change from same quarter last year.   I used field Parameters to create a start quarter selection and loaded all the measures except the last quarter (Q4/2025, i know it hasn't occured yet).  I also used a second field Parameter to create an end quarter selection and loaded all the quarters except q1/2024.  

 

When i add those fields from the field paramater into my matrix it works great and is Dynamic!

 

I would love to create 2 measures:

$ Change=End Column Selection - Start Column Selection 

% Change= (End Column Selection-Start Column Selection) / Start Column Selection

 

WHen i tried to do that using the below i get all sorts of errors. I tried with both SelectedMeasure and SelectedValue in the Var and neither works.  Any help getting this to dynamicly change would be amazing. 

 

% Change Dynamic =
    VAR StartValue =SELECTEDMEASURE('Start Column Selection'[Start Column Selection]) // Or SELECTEDVALUE if referring to a column directly
    VAR EndValue = SELECTEDMEASURE('End Column Selection'[End Column Selection]) // Or SELECTEDVALUE if referring to a column directly
 RETURN
        IF(
            NOT ISBLANK(StartValue) && NOT ISBLANK(EndValue) && StartValue <> 0,
            (EndValue - StartValue) / StartValue,
            BLANK()
        )
  • Hi  JimSales81 ,


    Well there isn't any explicit restriction on field parameters that would prevent us from using measure selection when working with two field parameters.
    Just that in practice, it isn’t behaving as expected when trying to create a dynamic difference between two field parameters.


    Thank you

10 Replies

  • Can you share the pbix via some cloud service?

     

    Anyway the solution to me is a visual calculation, but I need to see the matrix to give you he code (or you share th epbix and I do on the pbix directly)

     

    If this helped, please consider giving kudos and mark as a solution

    me in replies or I'll lose your thread

    Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page

    Consider voting this Power BI idea

    Francesco Bergamaschi

    MBA, M.Eng, M.Econ, Professor of BI

     

     

     

  • Hi, I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

    Please check the below picture and the attached pbix file.

     

     

     

     

     

     

    • JimSales81's avatar
      JimSales81
      Helper I

      This is not exactly what i am looking for.  I want to use the measure selection from the 2 different field paramenters to be compared. 

  • v-nmadadi-msft's avatar
    v-nmadadi-msft
    Community Support

    Hi JimSales81 
    Thanks for reaching out to the Microsoft fabric community forum.

    Since using two field parameter selections as variables isn't yielding the desired results, consider modifying your approach by creating two separate measures  one for 'Compare with Previous Quarter' and another for 'Compare with Same Quarter Last Year'. Then, use a field parameter to allow users to select only the end quarter.

    The start quarter will be dynamically determined within each measure based on the selected comparison type.

    Instead of relying on both a start and end quarter selection via field parameters, simplify the design by allowing users to select only the end quarter using a field parameter. Then, create two separate comparison measures:

    • One measure to calculate the difference from the previous quarter.
    • Another measure to calculate the difference from the same quarter in the previous year.

    Each of these measures will internally determine the appropriate start quarter by offsetting the selected end quarter. For example:

    • The “Compare with Previous Quarter” measure will find the quarter immediately before the selected end quarter.
    • The “Compare with Same Quarter Last Year” measure will look 4 quarters back.

    These calculations can be handled within DAX using functions like DATEADD, PARALLELPERIOD, or custom quarter logic using a date table.



    I hope this information helps. Please do let us know if you have any further queries.
    Thank you

    • JimSales81's avatar
      JimSales81
      Helper I

      I had a solution like this but sometimes the users like to pick Random quarters to compare like Q3 2024 vs Q2 2025.  My  solution would solve for that.  Can we confirm at the current time measures between 2 field parameters can not be done?

      • v-nmadadi-msft's avatar
        v-nmadadi-msft
        Community Support

        Hi  JimSales81 ,


        Well there isn't any explicit restriction on field parameters that would prevent us from using measure selection when working with two field parameters.
        Just that in practice, it isn’t behaving as expected when trying to create a dynamic difference between two field parameters.


        Thank you

  • v-nmadadi-msft's avatar
    v-nmadadi-msft
    Community Support

    Hi JimSales81 

    I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.


    Thank you.

  • v-nmadadi-msft's avatar
    v-nmadadi-msft
    Community Support

    Hi JimSales81 

    May I check if this issue has been resolved? If not, Please feel free to contact us if you have any further questions.


    Thank you

  • Hi JimSales81 ,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the suggestions  provided by the community members for the issue worked. Please feel free to contact us if you have any further questions.

     

    Thanks and regards