Forum Discussion

NewbieJono's avatar
NewbieJono
Post Partisan
3 years ago
Solved

Sync Y Axis

hello all, any ideas what DAXi could use to sync the two y Axis on the following charts. the data comes from two different tables.

 

i guess I want to find the max value of the max month from both charts.

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi  NewbieJono ,

     

    Here are the steps you can follow:

    1. Create calculated table.

    Table =
    var _table1=
    SUMMARIZE(
    'Table1',Table1[Date],"Value",SUMX(FILTER(ALL(Table1),YEAR('Table1'[Date])=YEAR(EARLIER('Table1'[Date]))&&MONTH('Table1'[Date])=MONTH(EARLIER('Table1'[Date]))),[Value1]),"Table","Table1")
        var _table2=
    SUMMARIZE(
    'Table2',Table2[Date],"Value",SUMX(FILTER(ALL(Table2),YEAR('Table2'[Date])=YEAR(EARLIER('Table2'[Date]))&&MONTH('Table2'[Date])=MONTH(EARLIER('Table2'[Date]))),[Value2]),"Table","Table2")
    var _table3=
    UNION(_table1,_table2)
    var _table4=
    FILTER(
        _table3,
       [Value]=MAXX(FILTER(_table3,[Table]=EARLIER([Table])&&YEAR([Date])=YEAR(EARLIER([Date]))),[Value]))
    return
    _table4

    2. Create measure.

    Flag =
    var _column1=SELECTCOLUMNS(FILTER('Table','Table'[Table]="Table1"),"1",[Date])
    var _column2=SELECTCOLUMNS(FILTER('Table','Table'[Table]="Table2"),"2",[Date])
    return
        IF(
        NOT(MAX('Table2'[Date])) in _column2,1,
        IF(
        NOT(MAX('Table1'[Date])) in _column1 ,0,1)
    )

    3. Set [Flag] to is=1 in Table 1 and set [Flag] to is=0 in Table2.

     

    4. Result:

     

    Best Regards,

    Liu Yang

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

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi  NewbieJono ,

     

    Here are the steps you can follow:

    1. Create calculated table.

    Table =
    var _table1=
    SUMMARIZE(
    'Table1',Table1[Date],"Value",SUMX(FILTER(ALL(Table1),YEAR('Table1'[Date])=YEAR(EARLIER('Table1'[Date]))&&MONTH('Table1'[Date])=MONTH(EARLIER('Table1'[Date]))),[Value1]),"Table","Table1")
        var _table2=
    SUMMARIZE(
    'Table2',Table2[Date],"Value",SUMX(FILTER(ALL(Table2),YEAR('Table2'[Date])=YEAR(EARLIER('Table2'[Date]))&&MONTH('Table2'[Date])=MONTH(EARLIER('Table2'[Date]))),[Value2]),"Table","Table2")
    var _table3=
    UNION(_table1,_table2)
    var _table4=
    FILTER(
        _table3,
       [Value]=MAXX(FILTER(_table3,[Table]=EARLIER([Table])&&YEAR([Date])=YEAR(EARLIER([Date]))),[Value]))
    return
    _table4

    2. Create measure.

    Flag =
    var _column1=SELECTCOLUMNS(FILTER('Table','Table'[Table]="Table1"),"1",[Date])
    var _column2=SELECTCOLUMNS(FILTER('Table','Table'[Table]="Table2"),"2",[Date])
    return
        IF(
        NOT(MAX('Table2'[Date])) in _column2,1,
        IF(
        NOT(MAX('Table1'[Date])) in _column1 ,0,1)
    )

    3. Set [Flag] to is=1 in Table 1 and set [Flag] to is=0 in Table2.

     

    4. Result:

     

    Best Regards,

    Liu Yang

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

  • NewbieJono , You need to have common date/dimension tables for that

     

    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

     

    Power BI- Power Query: When I asked you to create common tables: https://youtu.be/PqfGW6pl1Sw

     

    Also check out

    Power BI Field Parameters — A Quick way for Dynamic Visuals: https://amitchandak.medium.com/power-bi-field-parameters-a-quick-way-for-dynamic-visuals-fc4095ae9afd
    Power BI Field Parameters- Measure Slicer and Axis/Dimension slicer: https://youtu.be/lqF3Wa1FllE

    • NewbieJono's avatar
      NewbieJono
      Post Partisan

      Sorry! i meant the X-axis!

       

      so for the above charts I would need a max of 164