The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hi, I'm looking for a formula that can make the following:
I have a Column (A) with values and I need to have a new column (B) with the result of the multiplication of:
Column A formula Column B
A1 A1=B1 = B1
A2 B1 x A2 = B2
A3 B2 x A3 = B3
A4 B3 x A4 = B4 ...
What I have currently:
What I need:
Please and thank you!
This looks like a recursive definition. While DAX cannot handle recursion, it's often possible to reformulate the definition non-recursively. See this post for a similar situation.
This particular case looks fairly easy to reformulate. Column B is the cumulative product of A. Assuming you have some sort of indexing column to define the order of A (if not, add an index column in the query editor), you can define a calculated column B as follows:
B =
VAR CurrIndex = Table1[Index]
RETURN
PRODUCTX ( FILTER ( Table1, Table1[Index] <= CurrIndex ), Table1[A] )
@AlexisOlson Thanks for the reply, I've tried the formula but it seems to have an error.
This is my table with the full info I want to show, for "Total Piezas" and "A" I'm using measures and need another measure or calculated column to show results in "B"
Could you help me please?
I was assuming [A] was a table column rather than a measure. Without knowing how that measure is defined, it's hard to know what's going wrong.
@Anonymous If this is truly recursive, your odds of getting a DAX solution are slim. Believe me, I've tried over the years. Your best bet is to use Power Query as that can do true recursion.
DAX attempts at recursion with links to various attempts, work-arounds and how to do it in M: Previous Value (“Recursion”) in DAX – Greg Deckler
@Anonymous Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.