Forum Discussion

atziovara's avatar
atziovara
Icon for Helper I rankHelper I
2 years ago

X-AXIS ISSUE

I have one measure called Current Demand which starts from 01/01/2012 (2012 H1) and ends in 01/01/2023 (2023 H1) and another one called Future Demand which starts from 30/12/2012 (2012 H2) and ends in 30/06/2023 (2023 H2). These two measures belong in different tables (Table 1 and Table 2).

I want to place both these measures in one line and stacked column graph that shows the values of these two measures for all semesters, starting from 01/01/2012 (2012 H1) and ends in 30/06/2023 (2023 H2).

I tried including both Semesters columns in the x-axis. However, when I put the semester column from Table 1 first on the x axis, I get back results from 01/01/2012 (2012 H1) to 01/01/2023 (2023 H1) and when I include the semester column from Table 2 first on the x axis, I get back results from 30/06/2012 (2012 H2) to 30/06/2023 (2023 H2).

3 Replies

  • atziovara , Based on what I got. Create a common date table and join it with both tables on date and use common table in visual, slicer and measure

     

    Power BI- DAX: When I asked you to create common tables: https://youtu.be/a2CrqCA9geM
    https://medium.com/@amitchandak/power-bi-when-i-asked-you-to-create-common-tables-a-quick-dax-solution-8e3eccb41bda

     

    Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
    https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

    • atziovara's avatar
      atziovara
      Icon for Helper I rankHelper I

      amitchandak 

      • My data set is like this:

        Table Name: TableBI
      WaveCompany IDWeightsQuestionsAnswersWeighted AnswersPeriods
      110,006Demand change compared to the previous 6 months-1-0,0062022 H2
      110,006Expected change in demand in the next 6 months10,0062023 H1
      110,006Liquidity problems intensity10,0062022 H2
      110,006Expected change in employment002023 H1
      120,001Demand change compared to the previous 6 months10,0012022 H2
      120,001Expected change in demand in the next 6 months10,0012023 H1
      120,001Liquidity problems intensity-1-0,0012022 H2
      120,001Expected change in employment10,0012023 H1
      130,0057Demand change compared to the previous 6 months10,00572022 H2
      130,0057Expected change in demand in the next 6 months002023 H1
      130,0057Liquidity problems intensity002022 H2
      130,0057Expected change in employment002023 H1
      210,006Demand change compared to the previous 6 months10,0062023 H1
      210,006Expected change in demand in the next 6 months002023 H2
      210,006Liquidity problems intensity002023 H1
      210,006Expected change in employment002023 H2
      220,001Demand change compared to the previous 6 months10,0012023 H1
      220,001Expected change in demand in the next 6 months10,0012023 H2
      220,001Liquidity problems intensity-1-0,0012023 H1
      220,001Expected change in employment10,0012023 H2
      230,0057Demand change compared to the previous 6 months10,00572023 H1
      230,0057Expected change in demand in the next 6 months002023 H2
      230,0057Liquidity problems intensity-1-0,00572023 H1
      230,0057Expected change in employment10,00572023 H2

      *Weighted Answers is calculated as: Weights * Answers

      **In the column "Answers" -1 denotes decrease (or zero problems for Liquidity problems intensity), 0 denotes stability (or low to medium intensity problems), and 1 denotes increase (or high intensity problems).

       

       

      • I have created the calculated column "Period" in Power BI as follows:

       

      Period = 

      IF(

          'TableBI'[Wave] = 1,

           IF(

                  ('TableBI'[Questions] = "Demand change compared to the previous 6 months" || 

                  'TableBI'[Questions] = "Liquidity problems intensity"),

                  "2022 H2",

                  "2023 H1"

               ),

              IF(

                   'TableBI'[Wave] = 2,

                   IF(

                          ('TableBI'[Questions] = "Demand change compared to the previous 6 months" || 

                          'TableBI'[Questions] = "Liquidity problems intensity"),

                          "2023 H1",

                          "2023 H2"

                       )
              )

           )

        )

       

      ***There are multiple waves in the original data

       

       

      • I have created the following DAX measure in order to compute the weighted average of Current Demand and the weighted average of Future Demand:
      Weighted Average =
      VAR SelectedCharacteristic = SELECTEDVALUE('TableBI'[Questions])
      RETURN
      DIVIDE(
      SUMX(
      FILTER(
      'TableBI',
      NOT(ISBLANK('TableBI'[Weighted Answers])) &&
      NOT(ISBLANK('TableBI'[Weights])) &&
      'TableBI'[Questions] = SelectedCharacteristic
      ),
      'TableBI'[Weights]
      ),
      SUMX(
      FILTER(
      'TableBI',
      NOT(ISBLANK('TableBI'[Weighted Answers])) &&
      NOT(ISBLANK('TableBI'[Weights])) &&
      'TableBI'[Questions] = SelectedCharacteristic
      ),
      'TableBI'[Weights]
      )
      )
       
       
      • I have placed a slicer with the values of column "Questions". I would like to be able to have the computed weighted average per Period both for Current Demand ("Demand change compared to the previous 6 months") and for Future Demand ("Expected change in demand in the next 6 months") without creating different measures every time I want to compare the weighted average of the answers of two or more questions. 

       

      • I created a disconnected table called 'Table2' by duplicating 'TableBI'. I also created another calculated column called 'Period' on the new table with the same formula as the first.

       

      • I included a slicer that takes its values from 'Table2'[Questions].

       

      • I created a new measure on Table2:

       

      Weighted Average Disconnected =
      CALCULATE(
      [Weighted Average],
      TREATAS(
      VALUES('Table2'[Questions]),
      TableBI[Questions]
      )
      )
       
      • I added a line and stacked column graph. Its Column Values is the Weighted Average (from 'TableBI'), and its Line Values is Weighted Average Disconnected (from 'Table2'). I selected "Expected change in demand in the next 6 months" on the first slicer (from 'TableBI') and "Demand change compared to the previous 6 months" on the second slicer ('Table2').

       

      • I want to have Period on the Shared Axis. I want to be able to show the fact that Current Demand starts on 2022 H2 and ends on 2023 H1, as well as that Future Demand is 6 months ahead, which means that it is blank on 2022 H2, as it starts on 2023 H1and ends on 2023 H2 (when Current Demand is blank). However, when the Shared Axis takes its values from "Period" of 'TableBI' the data of the graph start from 2023 H1 and end on 2023 H2. And when the Shared Axis takes its values from "Period" of 'Table2' the data of the graph start from 2022 H2 and end on 2023 H1. 
  • amitchandak 

     

    • My data set is like this:

      Table Name: TableBI
    WaveCompany IDWeightsQuestionsAnswersWeighted AnswersPeriods
    110,006Demand change compared to the previous 6 months-1-0,0062022 H2
    110,006Expected change in demand in the next 6 months10,0062023 H1
    110,006Liquidity problems intensity10,0062022 H2
    110,006Expected change in employment002023 H1
    120,001Demand change compared to the previous 6 months10,0012022 H2
    120,001Expected change in demand in the next 6 months10,0012023 H1
    120,001Liquidity problems intensity-1-0,0012022 H2
    120,001Expected change in employment10,0012023 H1
    130,0057Demand change compared to the previous 6 months10,00572022 H2
    130,0057Expected change in demand in the next 6 months002023 H1
    130,0057Liquidity problems intensity002022 H2
    130,0057Expected change in employment002023 H1
    210,006Demand change compared to the previous 6 months10,0062023 H1
    210,006Expected change in demand in the next 6 months002023 H2
    210,006Liquidity problems intensity002023 H1
    210,006Expected change in employment002023 H2
    220,001Demand change compared to the previous 6 months10,0012023 H1
    220,001Expected change in demand in the next 6 months10,0012023 H2
    220,001Liquidity problems intensity-1-0,0012023 H1
    220,001Expected change in employment10,0012023 H2
    230,0057Demand change compared to the previous 6 months10,00572023 H1
    230,0057Expected change in demand in the next 6 months002023 H2
    230,0057Liquidity problems intensity-1-0,00572023 H1
    230,0057Expected change in employment10,00572023 H2

    *Weighted Answers is calculated as: Weights * Answers

    **In the column "Answers" -1 denotes decrease (or zero problems for Liquidity problems intensity), 0 denotes stability (or low to medium intensity problems), and 1 denotes increase (or high intensity problems).

     

     

    • I have created the calculated column "Period" in Power BI as follows:

     

    Period = 

    IF(

        'TableBI'[Wave] = 1,

         IF(

                ('TableBI'[Questions] = "Demand change compared to the previous 6 months" || 

                'TableBI'[Questions] = "Liquidity problems intensity"),

                "2022 H2",

                "2023 H1"

             ),

            IF(

                 'TableBI'[Wave] = 2,

                 IF(

                        ('TableBI'[Questions] = "Demand change compared to the previous 6 months" || 

                        'TableBI'[Questions] = "Liquidity problems intensity"),

                        "2023 H1",

                        "2023 H2"

                     )
            )

         )

      )

     

    ***There are multiple waves in the original data

     

     

    • I have created the following DAX measure in order to compute the weighted average of Current Demand and the weighted average of Future Demand:
    Weighted Average =
    VAR SelectedCharacteristic = SELECTEDVALUE('TableBI'[Questions])
    RETURN
    DIVIDE(
    SUMX(
    FILTER(
    'TableBI',
    NOT(ISBLANK('TableBI'[Weighted Answers])) &&
    NOT(ISBLANK('TableBI'[Weights])) &&
    'TableBI'[Questions] = SelectedCharacteristic
    ),
    'TableBI'[Weights]
    ),
    SUMX(
    FILTER(
    'TableBI',
    NOT(ISBLANK('TableBI'[Weighted Answers])) &&
    NOT(ISBLANK('TableBI'[Weights])) &&
    'TableBI'[Questions] = SelectedCharacteristic
    ),
    'TableBI'[Weights]
    )
    )
     
     
    • I have placed a slicer with the values of column "Questions". I would like to be able to have the computed weighted average per Period both for Current Demand ("Demand change compared to the previous 6 months") and for Future Demand ("Expected change in demand in the next 6 months") without creating different measures every time I want to compare the weighted average of the answers of two or more questions. 

     

    • I created a disconnected table called 'Table2' by duplicating 'TableBI'. I also created another calculated column called 'Period' on the new table with the same formula as the first.

     

    • I included a slicer that takes its values from 'Table2'[Questions].

     

    • I created a new measure on Table2:

     

    Weighted Average Disconnected =
    CALCULATE(
    [Weighted Average],
    TREATAS(
    VALUES('Table2'[Questions]),
    TableBI[Questions]
    )
    )
     
    • I added a line and stacked column graph. Its Column Values is the Weighted Average (from 'TableBI'), and its Line Values is Weighted Average Disconnected (from 'Table2'). I selected "Expected change in demand in the next 6 months" on the first slicer (from 'TableBI') and "Demand change compared to the previous 6 months" on the second slicer ('Table2').

     

    • I want to have Period on the Shared Axis. I want to be able to show the fact that Current Demand starts on 2022 H2 and ends on 2023 H1, as well as that Future Demand is 6 months ahead, which means that it is blank on 2022 H2, as it starts on 2023 H1and ends on 2023 H2 (when Current Demand is blank). However, when the Shared Axis takes its values from "Period" of 'TableBI' the data of the graph start from 2023 H1 and end on 2023 H2. And when the Shared Axis takes its values from "Period" of 'Table2' the data of the graph start from 2022 H2 and end on 2023 H1.