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
pledington
Frequent Visitor

Matrix - Dates on both axis showing % based on running totals

Hi, I want to repicate a table I have easily created in excel into Power BI and tried to use a Matrix to show the below table from excel but it isn't working for me:

 

Capture 1.PNG

This was the excel formula: =IFERROR(SUMIFS(Data!$D:$D;Data!$B:$B;"<="&E$3;Data!$A:$A;$B5)/SUMIFS(Data!$C:$C;Data!$A:$A;$B5);"")

 

I created a table with the blow data from the excel file:

Capture 2.PNG

I then created some quick measures like this:

 

Offer Price running total in Estimated Close Date =
CALCULATE(
 SUM('Data'[Offer Price]);
 FILTER(
  ALLSELECTED('Data'[Estimated Close Date]);
  ISONORAFTER('Data'[Estimated Close Date]; MAX('Data'[Estimated Close Date]); DESC)
 )
)

 

Trying to create a measure for the running total for both Invoice Value and Offer Price I then created another measure called conversion rate that divided the 2 but get the following Matrix:

Capture 3.PNG

 

The only column that is correct is the Total on the right, any help with this is appreciated.

2 ACCEPTED SOLUTIONS

Hi @pledington,

 

Based on my test, you should be able to follow steps below to create the Matrix in Power BI.

 

1. Add a individual Date table which contains the corresponding Month-Year data in your mode.

 

t1.PNG

 

2. Use the formulas below to create measures to calculate the Offer Price running total in Estimated Close Date.

Total Invoice = 
VAR invoiceDate =
    CALCULATE ( MAX ( 'Date'[Month Year] ), ALLSELECTED ( 'Date'[Month Year] ) )
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] ),
        ALLEXCEPT ( 'Date', 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            YEAR ( Table1[Invoice Date] ) <= YEAR ( invoiceDate )
                && MONTH ( Table1[Invoice Date] ) <= MONTH ( invoiceDate )&&NOT(ISBLANK(Table1[Invoice Date]))&&YEAR ( Table1[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( Table1[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )
Total Offer = 
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] ),
        ALLEXCEPT ( 'Date', 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            YEAR ( Table1[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( Table1[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )
Offer Price running total in Estimated Close Date = DIVIDE([Total Invoice],[Total Offer])

3. Then you should be able to show Date[Month Year] column as Rows and also as Columns, and [Offer Price running total in Estimated Close Date] as Values on the Matrix to get your expected result.

 

r1.PNG

 

Here is sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

Thanks @v-ljerr-msft that was very helpful. I tried this in my live data and only had to change it a little, the reason being I added a slicer uising the [Month Year] that can span a 4 year period but was stricted to a 2 year period and also wanted it based on cumulative $ values so the measures ended up looking something like this:

Total Offer = 
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] );
        ALLEXCEPT ( 'Date'; 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table1'[Expected Revenue] );
        FILTER (
            'Table1';
            YEAR ( 'Table1'[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( 'Table1'[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )

 

Total Invoice = 
VAR invoiceDate =
    CALCULATE ( MAX ( 'Date'[Month Year] ); ALLSELECTED ( 'Date'[Month Year] ) )
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] );
        ALLEXCEPT ( 'Date'; 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table1'[Invoice Value]);
        FILTER (
            'Table1'; 'Table1'[Invoice Date] <= invoiceDate
                &&NOT(ISBLANK('Table1'[Invoice Date]))&&YEAR ( 'Table1'[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( 'Table1'[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )

 

View solution in original post

4 REPLIES 4
CheenuSing
Community Champion
Community Champion

Hi @pledington

 

 

Can you please share some data and the business logic to build the final output expected to help fina solution.

 

Put the data in one drive and share the link.

 

Cheers

 

CheenuSing

Did I answer your question? Mark my post as a solution and also give KUDOS !

Proud to be a Datanaut!

Hi @CheenuSing thanks for your reply.

 

I have attached the sample data from the excel file: Sample data

 

Part of our business is tracking the conversion/renewal of sales, where the Offer price represents last year's sale and Invoice value is this year's sale and compares when the sale was due to be made and when it actually happened.

 

I currently produce a report that includes the table example I included from excel so that we can see as at each month end how sales are tracking and the lag of sales across time. For example if you look at Jun-17 from the top dates I can see that by the end of the month we had only closed 40% of the sales that were due for that month but we had already closed 67% of next month sales. Equally I can also see that by the end of Jul-17 we had closed 60% of sales due in Jun-17 and 80% by the end of Aug-17, meaning we re-gained 20% of Jun's due sales in both months. and as of right now we closed 80% of those Jun sales.

 

This is helpful as we like to know how each individual monthly sales (were the original sale was due, dates on the left) are tracking and as we track along each month end (dates along the top) we can see the lag effect on sales and here each month ended up. I do it as a table as bar and line graphs end up too busy.

Hi @pledington,

 

Based on my test, you should be able to follow steps below to create the Matrix in Power BI.

 

1. Add a individual Date table which contains the corresponding Month-Year data in your mode.

 

t1.PNG

 

2. Use the formulas below to create measures to calculate the Offer Price running total in Estimated Close Date.

Total Invoice = 
VAR invoiceDate =
    CALCULATE ( MAX ( 'Date'[Month Year] ), ALLSELECTED ( 'Date'[Month Year] ) )
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] ),
        ALLEXCEPT ( 'Date', 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            YEAR ( Table1[Invoice Date] ) <= YEAR ( invoiceDate )
                && MONTH ( Table1[Invoice Date] ) <= MONTH ( invoiceDate )&&NOT(ISBLANK(Table1[Invoice Date]))&&YEAR ( Table1[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( Table1[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )
Total Offer = 
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] ),
        ALLEXCEPT ( 'Date', 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            Table1,
            YEAR ( Table1[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( Table1[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )
Offer Price running total in Estimated Close Date = DIVIDE([Total Invoice],[Total Offer])

3. Then you should be able to show Date[Month Year] column as Rows and also as Columns, and [Offer Price running total in Estimated Close Date] as Values on the Matrix to get your expected result.

 

r1.PNG

 

Here is sample pbix file for your reference. Smiley Happy

 

Regards

Thanks @v-ljerr-msft that was very helpful. I tried this in my live data and only had to change it a little, the reason being I added a slicer uising the [Month Year] that can span a 4 year period but was stricted to a 2 year period and also wanted it based on cumulative $ values so the measures ended up looking something like this:

Total Offer = 
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] );
        ALLEXCEPT ( 'Date'; 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table1'[Expected Revenue] );
        FILTER (
            'Table1';
            YEAR ( 'Table1'[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( 'Table1'[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )

 

Total Invoice = 
VAR invoiceDate =
    CALCULATE ( MAX ( 'Date'[Month Year] ); ALLSELECTED ( 'Date'[Month Year] ) )
VAR closeDate =
    CALCULATE (
        MAX ( 'Date'[Month Year] );
        ALLEXCEPT ( 'Date'; 'Date'[Month Year] )
    )
RETURN
    CALCULATE (
        SUM ( 'Table1'[Invoice Value]);
        FILTER (
            'Table1'; 'Table1'[Invoice Date] <= invoiceDate
                &&NOT(ISBLANK('Table1'[Invoice Date]))&&YEAR ( 'Table1'[Estimated Close Date] ) = YEAR ( closeDate )
                && MONTH ( 'Table1'[Estimated Close Date] ) = MONTH ( closeDate )
        )
    )

 

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.