Forum Discussion
Problem with data for Scatter chart
- 1 year ago
Hi FrankWe ,
Thank you for your Patience..!!
I have created new table under "Table View" tab , please have a look at the attached pbix file.
If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it!
Thank you.
First of all , thank you for your reply. I already used the following measures in my model:
===============================
FWE GM Total (Visible Rows) =
====================
I think this should be okay so far, isn't it?
FrankWe ,
Thanks for the follow-up. Based on your message and the DAX snippets, it looks like you're trying to dynamically calculate values based on filtered context, and possibly apply tier logic or running calculations.
Since you're open to using Power Query, here's a basic example of how you can simulate the "Current Price" logic step-by-step using M code:
Power Query Steps:
Sort your data
Sort by IDCustomer, IDProduct, and Validity From (ascending).Add an Index column
This helps track the order of price changes.Group the data
Group by IDCustomer and IDProduct.Apply a custom function
Inside each group, use a loop to calculate the "Current Price" row by row:
(Table as table) =>
let
Sorted = Table.Sort(Table, {"Validity From", Order.Ascending}),
AddIndex = Table.AddIndexColumn(Sorted, "Index", 0, 1, Int64.Type),
AddPrice = Table.AddColumn(AddIndex, "Current Price", each
if [Index] = 0 then [OriginalPrice]
else null
),
FillDown = List.Accumulate(
{1..Table.RowCount(AddPrice)-1},
AddPrice,
(state, i) =>
let
prev = state{i-1}[Current Price],
coeff = state{i}[Coefficient],
updated = Table.ReplaceValue(state, null, prev * coeff, Replacer.ReplaceValue, {"Current Price"})
in
updated
)
in
FillDownThis logic assumes the first row starts with the original price and coefficient 1, and each following row multiplies the previous price by the current coefficient.
Let me know if you want me to help you plug this into your actual table or adjust it for your column names.