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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Heng
Frequent Visitor

Dynamic allocation cost by period based on Numeric Parameter

Dear All,
I have sale table and i would like to calculated a measure by allocat cost by construction period parameter selected.
Noted that I want it automatically changed when I change the construction period parameter.
Really appreciated for your help !
Best regards,
Heng
Numeric Parameter: 

Const Period Value = SELECTEDVALUE('Const Period'[Const Period],30)
Sale Table=


Sale DateUnit CodeConst Cost
01-Feb-23R15-H17618500
26-May-23R15-H125A30000
07-Aug-23R11-H4318500
06-Aug-23R13-H10718500
25-Feb-23R15-H16218500
11-Feb-23R05-H20A18500
24-Jul-23R11-H8118500
15-Mar-23R05-H05A18500
16-Mar-23R07-H5918500
04-Feb-23R07-H5218500
19-Aug-23R13-H9918500
14-Aug-23R13-H13818500
27-Aug-23R02-H10836000

 

My result example of 1 unit code: 

 

Sale DateUnit CodeConst CostConst PeriodPeriodConst DateMonthly Const Cost
01-Feb-23R15-H17618500303001-Mar-23616.67
01-Feb-23R15-H17618500302901-Apr-23616.67
01-Feb-23R15-H17618500302801-May-23616.67
01-Feb-23R15-H17618500302701-Jun-23616.67
01-Feb-23R15-H17618500302601-Jul-23616.67
01-Feb-23R15-H17618500302501-Aug-23616.67
01-Feb-23R15-H17618500302401-Sep-23616.67
01-Feb-23R15-H17618500302301-Oct-23616.67
01-Feb-23R15-H17618500302201-Nov-23616.67
01-Feb-23R15-H17618500302101-Dec-23616.67
01-Feb-23R15-H17618500302001-Jan-24616.67
01-Feb-23R15-H17618500301901-Feb-24616.67
01-Feb-23R15-H17618500301801-Mar-24616.67
01-Feb-23R15-H17618500301701-Apr-24616.67
01-Feb-23R15-H17618500301601-May-24616.67
01-Feb-23R15-H17618500301501-Jun-24616.67
01-Feb-23R15-H17618500301401-Jul-24616.67
01-Feb-23R15-H17618500301301-Aug-24616.67
01-Feb-23R15-H17618500301201-Sep-24616.67
01-Feb-23R15-H17618500301101-Oct-24616.67
01-Feb-23R15-H17618500301001-Nov-24616.67
01-Feb-23R15-H1761850030901-Dec-24616.67
01-Feb-23R15-H1761850030801-Jan-25616.67
01-Feb-23R15-H1761850030701-Feb-25616.67
01-Feb-23R15-H1761850030601-Mar-25616.67
01-Feb-23R15-H1761850030501-Apr-25616.67
01-Feb-23R15-H1761850030401-May-25616.67
01-Feb-23R15-H1761850030301-Jun-25616.67
01-Feb-23R15-H1761850030201-Jul-25616.67
01-Feb-23R15-H1761850030101-Aug-25616.67
1 ACCEPTED SOLUTION

Hi @Heng ,

 

Unfortunately dax can't implement dynamic rows.

 

If you would like to suggest  feature improvements, you may  vote the idea and comment here to improve this feature. It is a place for customers provide feedback about Microsoft Office products . What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

 

Best Regards,

Neeko Tang

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

3 REPLIES 3
Heng
Frequent Visitor

Dear Neeko,
Really appreciate for your great solution. However I want to do it in dax for my scenarion analysis
Kind regards,
Heng

Hi @Heng ,

 

Unfortunately dax can't implement dynamic rows.

 

If you would like to suggest  feature improvements, you may  vote the idea and comment here to improve this feature. It is a place for customers provide feedback about Microsoft Office products . What’s more, if a feedback is high voted there by other customers, it will be promising that Microsoft Product Team will take it into consideration when designing the next version in the future.

 

Best Regards,

Neeko Tang

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

v-tangjie-msft
Community Support
Community Support

Hi @Heng ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) Since desktop does not support dynamically changing the number of rows, you will need to add parameters to the power query.  Click "transform data" to enter the power query editor, open the "Advanced Editor" and copy and paste the following code.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XZA/CwIxDMW/S+cLJE3TP+MtUgQX13KDgrg4CTf47W0PhaRbIL+8vPdac0hwetzBs1vclQQqpdhHyoLotqU5H+Fy+2jAy9pnRvwRmGDdn3+CoAY2Chj1nrsCJvtCZg/RG4C0SeyAx9UqBDjvL2UhkxWQHuKtBFCsAEUNJKhSbIagHYz95LBMGYu9pzB3wNkm0CWiHyUNgOPR8vYF", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Sale Date" = _t, #"Unit Code" = _t, #"Const Cost" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Repeat("a,",Parameter1-1)&"a"),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Added Custom", {{"Custom", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Custom"),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Sale Date", type date}, {"Unit Code", type text}, {"Const Cost", Int64.Type}, {"Custom", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Custom"}),
    #"Added Custom1" = Table.AddColumn(#"Removed Columns", "Const Period", each Parameter1),
    #"Grouped Rows" = Table.Group(#"Added Custom1", {"Sale Date"}, {{"New", each Table.AddIndexColumn(_, "Index", Parameter1, -1, Int64.Type), type table [Sale Date=nullable date, Unit Code=nullable text, Const Cost=nullable number, Const Period=number]}}),
    #"Expanded  " = Table.ExpandTableColumn(#"Grouped Rows", "New", {"Unit Code", "Const Cost", "Const Period","Index"}, {"Unit Code", "Const Cost", "Const Period","Index"}),
    #"Added Custom2" = Table.AddColumn(#"Expanded  ", "Const Date", each Date.AddMonths([Sale Date],Parameter1-[Index]+1)),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Monthly Const Cost", each [Const Cost]/Parameter1)
in
    #"Added Custom3"

 

(3) Then the result is as follows.

vtangjiemsft_1-1691567867013.png

vtangjiemsft_2-1691567906403.png

 

Best Regards,

Neeko Tang

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.