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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Shahzz77
Frequent Visitor

How to multiply single value from one coloum to another using dax

I want to make a calcultion in DAX which includes Multiplication of single value with rest column values

For example in table

Ans = (Percentage 2020*sales2021) + (Percentage 2019*sales2021) +(Percentage 2018*sales2021)+(Percentage 2017*sales2021)

I want to create a measure for the above calculation which gives me the sale of 4 year. 

YearSalesPercentageSales of 4 year
201710000.2 
201820000.2 
201930000.2 
202040000.2 
202150000.2ans
9 REPLIES 9
v-henryk-mstf
Community Support
Community Support

Hi @Shahzz77 ,

 

According to your description, I did the test with the following reference:

M = 
VAR sel_year =
    SELECTEDVALUE ( 'Table'[Year] )
RETURN
    CALCULATE ( MAX ( 'Table'[Sales] ), 'Table'[Year] = sel_year )
        * CALCULATE (
            MAX ( 'Table'[Percentage] ),
            'Table'[Year] <= sel_year - 1
                && 'Table'[Year] >= sel_year - 4
        )

vhenrykmstf_0-1634695742264.png


If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

what if my percentage values are different then i cannot use max in my DAX. And also i have parameter for year sales like 4 3 2 to and the calculation changes accordingly . 4 year sales =2021*(percentage (2017+2018+2019+2020) and if 3 years = 2021*percentage(2018+2019+2020)

PERCENTAGE
0.2
0.4
0.3
0.5
0.2

 

lbendlin
Super User
Super User

Something like this (meta code)

ans = 
var y = selectedvalue(year)
return sumx(filter(table,year<y && year>y-6),percentage)*selectedvalue(sales)

 

 

Will this work in power bi dax?

ans = ?

what syntax i have to give 

would be hlpful if u can state a example.

Have you tried to use the DAX formula I provided?  You'll need to adjust it according to your actual table and column names.

Yes i tried but  it is showing error when i am selecting  columns in my table.

my actual table and colum names are

reserve =

Var y = selectedvalue(timeperiod)

return sumx (filter(table,year<y && year>y-6), percentage)* selectedvalue(sales)

 

It is showing error in filter table and also i am not able to select my percentage column.

You need to create a measure and in it need to specify the actual table names.

sumx (filter(table,year<y && year>y-6), percentage)* selectedvalue(sales)

What is y-6 .. why it is used

You had indicated that you wanted to see the previous four years of data . 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.