Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Line and column chart with 2 accumulated value lines, one per year

Hello,

 

I'm using two tables:  F_AMOUNTS and F_KPIS
F_AMOUNTS  has following columns: MONTH, GROUP and AMOUNT
For every month and for every group the table countains an amount. A month is refered to by the last day of the month. 

F_AMOUNTS.png
F_KPIS  has following columns: YEAR, GROUP and KPI
For every year and for every group the table countains a KPI amount. A year is refered to by the last day of the year.

F_KPIS.png

 

 

 

 

 

 

I added following 4 columns to F_AMOUNTS:

Month Abreviation = FORMAT(F_AMOUNTS[MONTH];"MMM")            Month Abriviation is sorted by Month Order 
Month Order = MONTH(F_AMOUNTS[MONTH])
Year = YEAR(F_AMOUNTS[MONTH])

KPI Month = DIVIDE( LOOKUPVALUE(F_KPIS[KPI]; F_KPIS[YEAR]; DATE(YEAR(F_AMOUNTS[MONTH]);12;31); F_KPIS[GROUP];  F_AMOUNTS[GROUP]); 12)

For every month I calculate the acumulative amount separately per group and per year, using this measure:

Cumulated Amount = CALCULATE(  SUM(F_AMOUNT[AMOUNT]);  FILTER(  ALLSELECTED(F_AMOUNT);  F_AMOUNT[MONTH] <= MAX(F_AMOUNT[MONTH]) &&  F_AMOUNT[GROUP] = MAX(F_AMOUNT[GROUP]) &&  YEAR(F_AMOUNT[MONTH]) = YEAR(MAX(F_AMOUNT[MONTH]))  )


I also calculate for every month the acumulative KPI separately per group and per year, using this measure:

Cumulated KPI =  CALCULATE(  SUM(F_AMOUNTS[KPI MONTH]);  FILTER(  ALLSELECTED(F_AMOUNTS);  F_AMOUNTS[MONTH] <= MAX(F_AMOUNTS[MONTH]) &&  F_AMOUNTS[GROUP] = MAX(F_AMOUNTS[GROUP]) &&  YEAR(F_AMOUNTS[MONTH]) = YEAR(MAX(F_AMOUNTS[MONTH]))  )

MONTHGROUP Cumulated Amount Cumulated KPI
31/01/2019  A240167
28/02/2019  A446333
31/03/2019  A574500
30/04/2019  A661667
31/05/2019  A777833
30/06/2019  A8481000
31/07/2019  A10511167
31/08/2019  A12051333
30/09/2019  A14421500
31/10/2019  A16811667
30/11/2019  A19241833
31/12/2019  A21442000
31/01/2020  A250200
29/02/2020  A463400
31/03/2020  A706600
30/04/2020  A881800
31/05/2020  A11671000
30/06/2020  A12691200
31/07/2020  A14931400
31/08/2020  A17671600
30/09/2020  A18971800
31/10/2020  A20742000
30/11/2020  A21372200
31/12/2020  A22712400
31/01/2019  B136150
28/02/2019     B263300
31/03/2019  B376450
30/04/2019  B557600
31/05/2019  B656750
30/06/2019  B940900
31/07/2019  B11881050
31/08/2019  B14191200
30/09/2019  B15781350
31/10/2019  B16651500
30/11/2019  B18641650
31/12/2019  B20261800
31/01/2020  B138175
29/02/2020  B250350
31/03/2020  B358525
30/04/2020  B546700
31/05/2020  B800875
30/06/2020  B8711050
31/07/2020  B11141225
31/08/2020  B12681400
30/09/2020  B13551575
31/10/2020  B15411750
30/11/2020  B16491925
31/12/2020  B18152100
 

I'm using a Line and Clustered Column Chart with Month Abreviation on shared axis, column series Year, column values Cumulated Amount and line values Cumulated KPI.

If I add a slicer on GROUP en select A then I get this result:

 

cumm_A_Line 1.png

 

But I would like to have two lines: one for the Cumulated KPI over 2019 and one for he Cumulated KPI over 2020 as I also have the Cumulated Amount for 2019 and for 2020 in the columns

Something like this:

 

cumm_A_Line 2.png

 

Does anybody have an idea how to do this?

Thanks,

 

R.W.

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

The 'Column series' field is just applied for the columns, not for lines. So you may need to create measures for each year to calculate:

2019 Cumulated KPI = 
CALCULATE (
    SUM ( 'F_AMOUNTS'[KPI Month] ),
    FILTER (
        ALL ( F_AMOUNTS ),
        MONTH ( 'F_AMOUNTS'[MONTH] ) <= MONTH ( MAX ( 'F_AMOUNTS'[MONTH] ) )
            && YEAR ( 'F_AMOUNTS'[MONTH] ) = 2019
            && 'F_AMOUNTS'[GROUP] IN DISTINCT ( 'F_AMOUNTS'[GROUP] )
    )
)
2020 Cumulated KPI = 
CALCULATE (
    SUM ( 'F_AMOUNTS'[KPI Month] ),
    FILTER (
        ALL ( F_AMOUNTS ),
        MONTH ( 'F_AMOUNTS'[MONTH] ) <= MONTH ( MAX ( 'F_AMOUNTS'[MONTH] ) )
            && YEAR ( 'F_AMOUNTS'[MONTH] ) = 2020
            && 'F_AMOUNTS'[GROUP] IN DISTINCT ( 'F_AMOUNTS'[GROUP] )
    )
)

re.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @v-yingjl 

Thanks for this solution.
But I also had to rewrite my other measures in the same style:

 

2019 Cumulated Amount = 
CALCULATE (
    SUM ( 'F_AMOUNTS'[Amount] ),
    FILTER (
        ALL ( F_AMOUNTS ),
        MONTH ( 'F_AMOUNTS'[MONTH] ) <= MONTH ( MAX ( 'F_AMOUNTS'[MONTH] ) )
            && YEAR ( 'F_AMOUNTS'[MONTH] ) = 2019
            && 'F_AMOUNTS'[GROUP] IN DISTINCT ( 'F_AMOUNTS'[GROUP] )
    )
)

 

 

 

 

2020 Cumulated Amount = 
CALCULATE (
    SUM ( 'F_AMOUNTS'[Amount] ),
    FILTER (
        ALL ( F_AMOUNTS ),
        MONTH ( 'F_AMOUNTS'[MONTH] ) <= MONTH ( MAX ( 'F_AMOUNTS'[MONTH] ) )
            && YEAR ( 'F_AMOUNTS'[MONTH] ) = 2020
            && 'F_AMOUNTS'[GROUP] IN DISTINCT ( 'F_AMOUNTS'[GROUP] )
    )
)

 

 

 

And I had to drop the Legend value Year.
So I have two measures for the columns en two measures for the lines.

R.W.

 

v-yingjl
Community Support
Community Support

Hi @Anonymous ,

The 'Column series' field is just applied for the columns, not for lines. So you may need to create measures for each year to calculate:

2019 Cumulated KPI = 
CALCULATE (
    SUM ( 'F_AMOUNTS'[KPI Month] ),
    FILTER (
        ALL ( F_AMOUNTS ),
        MONTH ( 'F_AMOUNTS'[MONTH] ) <= MONTH ( MAX ( 'F_AMOUNTS'[MONTH] ) )
            && YEAR ( 'F_AMOUNTS'[MONTH] ) = 2019
            && 'F_AMOUNTS'[GROUP] IN DISTINCT ( 'F_AMOUNTS'[GROUP] )
    )
)
2020 Cumulated KPI = 
CALCULATE (
    SUM ( 'F_AMOUNTS'[KPI Month] ),
    FILTER (
        ALL ( F_AMOUNTS ),
        MONTH ( 'F_AMOUNTS'[MONTH] ) <= MONTH ( MAX ( 'F_AMOUNTS'[MONTH] ) )
            && YEAR ( 'F_AMOUNTS'[MONTH] ) = 2020
            && 'F_AMOUNTS'[GROUP] IN DISTINCT ( 'F_AMOUNTS'[GROUP] )
    )
)

re.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.