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.
Hi, sorry im new to power BI. i tried to calculate the percentage different of totalamount between two years but failed.
steps that i had performed.
1) edit queries, i have 3 columns( monthname,totalamount,year), i pivot monthname with totalamount.
2) in the table result when i select the these three columns it will show as below
3) how can i insert the formula to calculate the percentange different of totalamount between this two years and show the result in new row ?
expected output.
year | september | october
2018 RM267068 RM677855
2019 RM1205141 RM968686
Diff. 3.512 0.42
Total RM1,205141 RM968.686
Solved! Go to Solution.
@Anonymous ,
In query editor, click september and october, then click "unpivot", after apply&close like below:
Then create a calculate column using dax below:
diff =
VAR Current_Year = 'Table'[year]
VAR Previous_Year = Current_Year - 1
RETURN
SWITCH (
'Table'[Attribute],
"september", (
CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "september"
&& 'Table'[year] = Current_Year
)
)
- CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "september"
&& 'Table'[year] = Previous_Year
)
)
)
/ CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "september"
&& 'Table'[year] = Previous_Year
)
),
"october", (
CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "october"
&& 'Table'[year] = Current_Year
)
)
- CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "october"
&& 'Table'[year] = Previous_Year
)
)
)
/ CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "october"
&& 'Table'[year] = Previous_Year
)
)
)
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
What result would you expect when you have more than 2 years of data?
@Anonymous ,
In query editor, click september and october, then click "unpivot", after apply&close like below:
Then create a calculate column using dax below:
diff =
VAR Current_Year = 'Table'[year]
VAR Previous_Year = Current_Year - 1
RETURN
SWITCH (
'Table'[Attribute],
"september", (
CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "september"
&& 'Table'[year] = Current_Year
)
)
- CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "september"
&& 'Table'[year] = Previous_Year
)
)
)
/ CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "september"
&& 'Table'[year] = Previous_Year
)
),
"october", (
CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "october"
&& 'Table'[year] = Current_Year
)
)
- CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "october"
&& 'Table'[year] = Previous_Year
)
)
)
/ CALCULATE (
MAX ( 'Table'[Value] ),
FILTER (
'Table',
'Table'[Attribute] = "october"
&& 'Table'[year] = Previous_Year
)
)
)
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
108 | |
100 | |
78 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |