Forum Discussion

mick22's avatar
mick22
Frequent Visitor
4 years ago
Solved

How would I do a dynamic visualization to show for Current and Next 12 Months Total Sales.

I have a main table dataset (Table 2 below) that is imported in to PowerBI Desktop that contains a list of customers, agreements, the current monthly price and date range of how long that agreement g...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  mick22 ,

    Here are the steps you can follow:

    1. Create calculated table2.

    Table2:

    Table 2 =

    CALENDAR(MIN('Table'[StartDate]),MAX('Table'[EndDate]))

    Create the calculated column in Table2:

    Year1 =
    VALUE( FORMAT('Table 2'[Date],"yyyymm"))
    Year2 =
    VALUE( FORMAT('Table 2'[Date],"yyyymm"))

    2. Create calculated table3.

    Table3

    Table 3 =
    DISTINCT('Table 2'[Year2])

    3. Create measure.

    Flag =
    var _1=CALCULATE(SUM('Table'[CurrentMonthlyPrice]),FILTER(ALL('Table 2'),'Table 2'[Year1]>=VALUE( FORMAT(MAX('Table'[StartDate]),"yyyymm"))&&MAX('Table 3'[Year2])<=VALUE( FORMAT(MAX('Table'[EndDate]),"yyyymm"))))
    return
    IF(
    MAX('Table 3'[Year2])<=MAX('Table 2'[Year1]),_1
    ,0)
    Total_Incorrect =
    var _table=SUMMARIZE('Table 2','Table 2'[Year1],"_value",[Flag])
    return
    IF(HASONEVALUE('Table 2'[Year1]),[Flag],SUMX(_table,[_value]))

    4. Result:

    Refer to:

    https://community.powerbi.com/t5/Desktop/Create-Lower-Triangular-Matrix/m-p/854339

     

    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