Forum Discussion

JasMack's avatar
JasMack
Frequent Visitor
3 years ago
Solved

Get a summary table from transaction table

Hi everyone,

 

I am new here.

 

I have a table which looks like this.

 

TeamPersonPeriodCostRevenue
ATom1100200
ATom2150100
AJack15090
AJack27580
BSarah1300400
BSarah2150500

 

Can you please help me with the achieving the following results on Power BI desktop using the table above?

 

ParticularPrior Month (Period <2)Year to date
Cost450825
Revenue6901370

 

Thanks.

 

Jason

  • JasMack Create a disconnected table like this:

    Particulars = { "Cost", "Revenue" }

    Create these measures:

    Revenue YTD = SUM('Table'[Revenue])
    
    Cost YTD = SUM('Table'[Cost])
    
    Revenue Prior = SUMX(FILTER('Table',[Period] = 1), [Revenue])
    
    Cost Prior = SUMX(FILTER('Table', [Period] = 1), [Cost])
    
    Prior Month (Period < 2) = IF(MAX('Particulars'[Column1]) = "Cost", [Cost Prior], [Revenue Prior])
    
    Year to Date = IF(MAX('Particulars'[Column1]) = "Cost", [Cost YTD], [Revenue YTD])

    Put Column1 from Particulars in your table visual along with the last 2 measures.

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    JasMack Create a disconnected table like this:

    Particulars = { "Cost", "Revenue" }

    Create these measures:

    Revenue YTD = SUM('Table'[Revenue])
    
    Cost YTD = SUM('Table'[Cost])
    
    Revenue Prior = SUMX(FILTER('Table',[Period] = 1), [Revenue])
    
    Cost Prior = SUMX(FILTER('Table', [Period] = 1), [Cost])
    
    Prior Month (Period < 2) = IF(MAX('Particulars'[Column1]) = "Cost", [Cost Prior], [Revenue Prior])
    
    Year to Date = IF(MAX('Particulars'[Column1]) = "Cost", [Cost YTD], [Revenue YTD])

    Put Column1 from Particulars in your table visual along with the last 2 measures.

    • JasMack's avatar
      JasMack
      Frequent Visitor

      Many thanks Greg_Deckler .

       

      But I have 2 more questions.

      1. My result table automatically gets sorted alphabetically. Is there a way to stop that. For example: I would prefer to have "Revenue" instead of "Cost" as first row.

      ParticularPrior Month (Period <2)Year to date
      Cost450825
      Revenue6901370

       

      2. Suppose I need to have put the values in row revenue in percentage format. Is it possible?

       

      Thank you again.

      Jason