Forum Discussion

arsene49's avatar
arsene49
Helper I
3 years ago
Solved

DAX Measure/Column Help

Hi All, Need a help to create DAX measure/column.

There are 2 tables, below is the sample data
1.Year-Factor
which has Factor for each year

Year    Factor
2021    1.035
2022    1.035
2023    1.035
None   1


2.Fact
there will be muliple products, multiple years and price

Product Year Price
A        2020    10
B        2021    15
C        2022    20


Requirement -
there will be Year slicer in the page from Year-Factor table and user will be choosing the year

 

ex. when they select 2022
if we look at the fact table:
expected output -
for product A which belongs to year 2020
output= price * 2021factor * 2022factor (10*1.04*1.04)
for product B which belongs to year 2021
output= price * 2022factor

final measure output - sum of Product A output + Product B output + Product C output

 

ex. when they select 2023
expected output - 
for product A which belongs to year 2020
output= price * 2021factor * 2022factor * 2023factor(10*1.04*1.04*1.04)
for product B which belongs to year 2021
output= price * 2022factor *2023factor

final measure output - sum of Product A output + Product B output + Product C output

 

ex. when they select None, 
for Product A , measure output is just Price

 

expected output when each year selected:

   filter selection in slicer
ProductYearPrice2021 selected2022 selected     2023 selected     

    None Selected

A20201010.3510.71225   11.08717875    10
B2021151515.525   16.068375    15
C2022202020   20.7    20

12 Replies

  • there will be Year slicer in the page from Year-Factor table and user will be choosing the year

    For that to work the Year-Factor table must be disconnected.

     

    Your expected output is unclear for products that fall outside the limits. Please indicate the expected outcome for all products and Year-Filter selections.

     

     

     

     

    • arsene49's avatar
      arsene49
      Helper I

      lbendlin Thanks for the reply. i have added a table at the end of the question which shows the expected output when each value of the Year-Factor slicer is selected. let me know if you need any further information.

      • arsene49's avatar
        arsene49
        Helper I

        lbendlin i have added expected outcome for all products and Year-Filter selections. did you get chance to look?

  • TotalCost=

    VAR selected=SELECTEDVALUE(Year-Factor[Year])

    VAR summed = SUMMARIZED('Fact',[Product],[Year],"PY")

    VAR year='Year-Factor'[Year]  

          RETURN 

               'Fact'[Price]*(year+1,[Factor],"yf")*(yf+1,[Factor])

    RETURN

        sumx(year,PY)