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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Isma
Frequent Visitor

Calculate weights in DAX

Hi,

Appreciate if someone could help me. Thank you

I have a pivot table and would like to add new measure

I would like to calculate weights for each row. Sample as below

if row number=1 then 0.06

else 0.94 * previous row value

Isma_0-1646748786561.png

Isma_1-1646749216436.png

 

 

 

 

1 ACCEPTED SOLUTION
v-rongtiep-msft
Community Support
Community Support

Hi @Isma ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
IF (
    MAX ( 'Table'[Row number] ) = 1,
    MAX ( 'Table'[Row number] ) * 0.06,
    0.06
        * POWER ( 0.94, MAX ( 'Table'[Row number] ) - 1 )
)

vpollymsft_1-1646980985897.png

If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output.

 

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.

 

 

 

 

View solution in original post

2 REPLIES 2
v-rongtiep-msft
Community Support
Community Support

Hi @Isma ,

Please refer to my pbix file to see if it helps you.

Create a measure.

Measure =
IF (
    MAX ( 'Table'[Row number] ) = 1,
    MAX ( 'Table'[Row number] ) * 0.06,
    0.06
        * POWER ( 0.94, MAX ( 'Table'[Row number] ) - 1 )
)

vpollymsft_1-1646980985897.png

If I have misunderstood your meaning, please provide your pbix file without privacy information and desired output.

 

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.

 

 

 

 

Jihwan_Kim
Super User
Super User

Hi,

Sorry that I only know how to do this in Power Query.

If you are interested in knowing how to do this in Power Query, please check the attached file.

 

1. Open pbix file

2. go to "Transform data"

3. New source -> blank query -> create a function.

   when you open advanced editor, you can see the query like below.

 

let
Source = (x as number) as number =>
let f = function(x-1) * 0.94
in
if x=1 then 0.06 else f
in
Source

 

 

4. In Data query, add invoke custom function. 

 

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors