Forum Discussion
Table Transformation with DAX
- 4 years ago
Hi Vikrant:
Off the top of my head I can't see a way to do that, (I'm sure someone knows). Generally, the when the data model is set up with fact and dim tables it allows for easier DAX and more complex analysis at the same time. Staying in one table can only take you so far.
Sorry if this doesn't do the table answer you'd like.
Here is one measure that produces the same results:(with the Date Table in Model)
MOM % Avg Price 2 =var monthavg = AVERAGEX(VALUES(Dates[Month]),average(TableA[Price]))var PrevMontPrice = CALCULATE([Monthly Avg], PREVIOUSMONTH(Dates[Date]))var currprice = SELECTEDVALUE(TableA[Price])var pricediff = monthavg - PrevMontPricevar monumber = SELECTEDVALUE(Dates[Month No.])returnIF( NOT(ISBLANK(currprice) && monumber >=2),DIVIDE(pricediff, [Prev Mont Price]))The Generate Table function might help here, not entirely sure...
Hi:
Please see attached link. I included a couple extra DAX formulas that show the build and included a Date Table to optimize these types of calculations.
https://drive.google.com/file/d/1DfLQlZaYxSzRJxnjljCwPu1MxvyRzFwV/view?usp=sharing
- VikrantC4 years agoHelper I
Hi,
I am able to do this. However, I want to create a virtual Table3 so that I can use in other formulas. Currently, I am taking the Table1 and I used a measure to created another table (Table2) to crate percentage. I am transposing it in Table3. Basically, I am trying to get to Table3 without creating Table2. If you can please help it will be nice. I can transpose the columns but I trying to transpose with a calculation (measure). Thanks.
- Whitewater1004 years agoSolution Sage
Hi Vikrant:
Off the top of my head I can't see a way to do that, (I'm sure someone knows). Generally, the when the data model is set up with fact and dim tables it allows for easier DAX and more complex analysis at the same time. Staying in one table can only take you so far.
Sorry if this doesn't do the table answer you'd like.
Here is one measure that produces the same results:(with the Date Table in Model)
MOM % Avg Price 2 =var monthavg = AVERAGEX(VALUES(Dates[Month]),average(TableA[Price]))var PrevMontPrice = CALCULATE([Monthly Avg], PREVIOUSMONTH(Dates[Date]))var currprice = SELECTEDVALUE(TableA[Price])var pricediff = monthavg - PrevMontPricevar monumber = SELECTEDVALUE(Dates[Month No.])returnIF( NOT(ISBLANK(currprice) && monumber >=2),DIVIDE(pricediff, [Prev Mont Price]))The Generate Table function might help here, not entirely sure...
- VikrantC4 years agoHelper I
Hi Whitewhater100,
Thank you very much. Unfortunately, it did not work.
Regards,