Forum Discussion

ashwinkolte's avatar
ashwinkolte
Helper III
3 years ago

Create a dynamic table with a calculated row

Create a new table from existing one with sliced data and add an additional row with calculations
a minute ago

hi

 

I have following table

Date                Col 1      Col 2     Col 3
01-01-2020    43566    100000   2
01-12-2020    23456    100000   3
30-06-2021    12345    100000   4
31-10-2022    43566    100000   2
30-11-2022    23456    100000   3
31-12-2022    12345    100000   4

User does the following :

Using Power Bi visual slicer , user keeps records only for year 2022 .

Following SHOULD HAPPEN

2) Automatically a dynamic table should be created as indicated below with an additonal last row with following calculations

2.1) Last row date should be latest date of the filtered data

2.2 ) COl 1 of Last row  should be (Value in col 1 of latest date * sum of col 3 of filtered rows )

Date             Col 1        Col 2        Col 3

31-10-2022  43566     100000      2
30-11-2022  23456     100000      3
31-12-2022  12345     100000      4
31-12-2022  12345*9

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi ashwinkolte ,

    Please refer to my pbix file.

    let
        Source = Table,
        #"2022" = Table.SelectRows(Source, each Date.Year([Date])=2022),
        Custom3 = Table.ToRecords(#"2022"),
        MaxDate = List.Max(Source[Date]),
        MaxCol1Value = Table.SelectRows(Source,each [Date]=MaxDate)[Col 1]{0},
        Total = List.Sum(Table.SelectRows(Source, each Date.Year([Date])<>2022)[Col 3]),
        Custom1 = Total,
        Custom2 = {[Date = MaxDate,Col 1=MaxCol1Value*Total,Col 2=null,Col 3=null]},
        Custom4 = Table.FromRecords(List.Combine({Custom3,Custom2}))
    in
        Custom4

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Polly

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

    • ashwinkolte's avatar
      ashwinkolte
      Helper III

      Dear  v-rongtiep-msft

       

      Thanks for your response. However as mentioned in my requirement , I need a dynamic table to be created when a user slices data  on BI visual and depending on which records user selects  in table 1. Is that possible ? 

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi ashwinkolte ,

        The dynamic addition of rows does not seem to be very feasible.

         

        Best Regards
        Community Support Team _ Polly

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