Forum Discussion

reddevil's avatar
reddevil
Helper II
1 year ago
Solved

Table to be created using the below format

Hi Everyone:

I have created a single measure for Prev and Current quarter and want to split it in a matrix using the below format, can someone guide me how do i achieve the below matrix table using the prev and current quarter measure using switch.

 

CategoryMeasureDirectionprevcurrdiffprevcurrdiffprevcurrdiffprevcurrdiff
Risk Index↑↓            
Issues# Open Issues1020102116-5104737770
>= M Issues 23132-127510-1
Average Resolution Time (days)19421016000444289-155132122-10
>= M Issues 484400-8411270-42442429-13280-28
Overdue Issues33043-1187000
>= M Issues 00010-1132000
Incidents# Open Incidents1020102116-525447-207770
>= M Incidents 23132-14447-43710-1
Average Resolution Time (days)1942101600044289245132122-10
>= M Incidents 484400-8411270-4234742982280-28
Overdue Issues33043-1128-4000
>= M Incidents 00010-1033000
  • Hi reddevil Could you try this please create measures first for three seperatly and then do SWITCH statement in dax please check this 

    1. Create Measures:
      Define prev , curr , and diff measures:

      PrevMeasure = CALCULATE(SUM(Table[Value]), FILTER(Table, Table[Quarter] = "Previous"))  
      CurrMeasure = CALCULATE(SUM(Table[Value]), FILTER(Table, Table[Quarter] = "Current"))  
      DiffMeasure = [CurrMeasure] - [PrevMeasure]  
    2. Dynamic Measure:

      SelectedMeasure = 
      SWITCH(
          TRUE(),
          SELECTEDVALUE(Table[MeasureType]) = "Prev", [PrevMeasure],
          SELECTEDVALUE(Table[MeasureType]) = "Curr", [CurrMeasure],
          SELECTEDVALUE(Table[MeasureType]) = "Diff", [DiffMeasure],
          BLANK()
      )
    3. Matrix Setup:

      Add Category and Measure to rows.

      Add MeasureType (Prev, Curr, Diff) to columns.

      Use SelectedMeasure as values.

    4. Apply conditional formatting for Direvtion as needed.

13 Replies

  • Hi reddevil Could you try this please create measures first for three seperatly and then do SWITCH statement in dax please check this 

    1. Create Measures:
      Define prev , curr , and diff measures:

      PrevMeasure = CALCULATE(SUM(Table[Value]), FILTER(Table, Table[Quarter] = "Previous"))  
      CurrMeasure = CALCULATE(SUM(Table[Value]), FILTER(Table, Table[Quarter] = "Current"))  
      DiffMeasure = [CurrMeasure] - [PrevMeasure]  
    2. Dynamic Measure:

      SelectedMeasure = 
      SWITCH(
          TRUE(),
          SELECTEDVALUE(Table[MeasureType]) = "Prev", [PrevMeasure],
          SELECTEDVALUE(Table[MeasureType]) = "Curr", [CurrMeasure],
          SELECTEDVALUE(Table[MeasureType]) = "Diff", [DiffMeasure],
          BLANK()
      )
    3. Matrix Setup:

      Add Category and Measure to rows.

      Add MeasureType (Prev, Curr, Diff) to columns.

      Use SelectedMeasure as values.

    4. Apply conditional formatting for Direvtion as needed.

    • reddevil's avatar
      reddevil
      Helper II

      Hi Akash_Varuna 

      We are calculating current measure like this : 

      VAR current__open=  CALCULATE(SUMX(Issues,[Total Open Issues]), FILTER(Issues, QUARTER(Issues[Create Date]) = QUARTER(TODAY())))
    • reddevil's avatar
      reddevil
      Helper II

      Hi Akash_Varuna 

      The current measure is calculated based on previous quarter -1 quarter and the previous quarter measure is just sumx(total open issues ), dateadd([max satatus date),-1, quarter). I also have a slicer which is based on created date Year/Quarter and Months.

    • reddevil's avatar
      reddevil
      Helper II

      Hi XiaoXin,

      I have already provided a table above which has measures in rows and there is previous and current quarters(columns) which needs to be calculated against those measures. There is also a date slicer on top. Please let me know if you require any further information.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi reddevil,

        The table you shared is a pivoted result table and it also not include any date fields. For these sample, we are hard to test and coding formula on it.

        For previous date calculation, you can add a variable to get the current date. Then you can use current category and the current date to find the max date that less than current date and category equal to the current category as previouse date.

        Regards,

        Xiaoxin Sheng

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Community Support

    Hi reddevil ,

    In additionto the Akash_Varuna , response.  To enhance the accuracy and flexibility of your time based filtering, replace string filters with proper time intelligence functions like QUARTER(TODAY()) or DATEADD().  This ensures calculations dynamically adjust to the current date context instead of relying on static text-based filters.

     

    Additionally, use VAR to store reusable values and maintain a dynamic date context that aligns with reporting periods. This improves clarity, performance, and consistency across different time-based metrics.

     

    If your table contains multiple metric types, consider creating separate dynamic measures (Selected_OpenIssues, Selected_ResolutionTime) to accurately represent distinct reporting needs. This method provides greater flexibility in visualizing and analyzing various data categories within your report.

     

    i Hope this helps...

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Community Support

    Hi reddevil ,

    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. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

    Thank You.

  • V-yubandi-msft's avatar
    V-yubandi-msft
    Community Support

    Hi reddevil ,

    May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

     

    Thank you.