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
avulasandeep
Helper III
Helper III

Need Difference and Percentage Difference for random selected years

 

Hi PowerBI Experts ,

i Need some dax formulas ,

Difference and Percentage Difference for Random Selected Years .

Suppose if i select years randomly like 2010 ,2012 ,2014, 2016

i need


1.Dax for Difference of sales  for 2010 and 2012 .....2012 and 2014 ......2014 and 2016

2.Dax for percentage difference for selected years


3.what percentage difference??????  if i select 10%  0r 20 % or 30%....what ever the percentage i select from the slicer i need that percentage sales only 

 

 

 

Is that Possible using Dax??? please help me out . here is screenshot

 

 

new files.jpeg





















Thanks in Advance 

Thanks 

Sandeep

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi Sandeep,

 

Please try the measures below.

Measure1 =
VAR lastSelectedYear =
    CALCULATE (
        LASTNONBLANK ( Table1[Years], 1 ),
        FILTER ( ALLSELECTED ( Table1[Years] ), Table1[Years] < MIN ( Table1[Years] ) )
    )
VAR lastSelectedYearSales =
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER ( ALL ( Table1[Years] ), Table1[Years] = lastSelectedYear )
    )
RETURN
    IF (
        ISBLANK ( lastSelectedYearSales ),
        BLANK (),
        SUM ( Table1[Sales] ) - lastSelectedYearSales
    )
Measure2 =
DIVIDE ( [Measure1], SUM ( Table1[Sales] ), 99999 )
//99999 means error here

Need-Difference-and-Percentage-Difference-for-random-selected-years

 

Best Regards,

Community Support Team _ Dale
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

1 REPLY 1
v-jiascu-msft
Employee
Employee

Hi Sandeep,

 

Please try the measures below.

Measure1 =
VAR lastSelectedYear =
    CALCULATE (
        LASTNONBLANK ( Table1[Years], 1 ),
        FILTER ( ALLSELECTED ( Table1[Years] ), Table1[Years] < MIN ( Table1[Years] ) )
    )
VAR lastSelectedYearSales =
    CALCULATE (
        SUM ( Table1[Sales] ),
        FILTER ( ALL ( Table1[Years] ), Table1[Years] = lastSelectedYear )
    )
RETURN
    IF (
        ISBLANK ( lastSelectedYearSales ),
        BLANK (),
        SUM ( Table1[Sales] ) - lastSelectedYearSales
    )
Measure2 =
DIVIDE ( [Measure1], SUM ( Table1[Sales] ), 99999 )
//99999 means error here

Need-Difference-and-Percentage-Difference-for-random-selected-years

 

Best Regards,

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

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.