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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

Difference between the min and Max Value.

Hi Team,

Need help 

 

I have a data as shown below and i have slicer with month.

NumberValueMonth
1223Jan
1234Feb
1223Mar
1264Apri
1254May
1276Jun
1254Jul
1212Aug
1398Jan
1312Feb
1334Mar
1345Apri
1356Jun
1376Jul
1367Aug
1365Sep
1332Oct

 

Requirement is to calculate the difference between the two values (If we select 3months ,it has to take min and max value of the selection) ,if there is no diff between the two values it has to return "No Diff", if the value is less "Decresed", if it is more "Increased".

 

Briefly - If i select April,may and june , it has to take april and june data and if the april value is more it should return "Decreased", If june is more than April it should return "Incresed".

 

 

Regards,

Suresh. 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

Step 1: Add a calculated column "MonthNumber"

 

 

MonthNumber = SWITCH([Month],
"Jan", 1,
"Feb", 2,
"Mar", 3,
"Apri", 4,
"May", 5,
"Jun", 6,
"Jul", 7,
"Aug", 8,
"Sep", 9,
"Oct", 10,
"Nov", 11,
"Dec", 12,
0
)

Define 4 measures (Not all of them are necessary. You can directly write the final measure by combining the formula into one.

 

 

Measure 1: Initial Figure

 

InitialFigure =
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( Table1, Table1[MonthNumber] = MIN ( Table1[MonthNumber] ) )
)

Measure 2: Final Figure

 

 

FinalFigure =
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( Table1, Table1[MonthNumber] = MAX ( Table1[MonthNumber] ) )
)

Measure 3: Difference

 

 

 

Difference = [FinalFigure] - [InitialFigure]

Measure 4: Trend

 

 

Trend = if([Difference]<0,"Decrease",IF([Difference]=0,"No Change","Increased"))

 

 

Now based on your month selection, these measures will give you the results.

 

Disclaimer: In the SWITCH() function, I have assigned 1 for January, 2 for February and so on... If you are following a financial year calendar like Apr to Mar, then you will have to assign 1 for Apr, 2 May, etc... and 10 for Jan, 11 for Feb, and 12 for Mar. Only then the beginning and ending period will be calculated correctly.

View solution in original post

Hi @Anonymous 

Attached sample file for your reference.It seems sreenathv's workaround is work for you.

Regards,

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

5 REPLIES 5
Cynwaa
Frequent Visitor

Hello, I know a way to achieve this but it is perhaps not the smartest way.

 

1. Instead of your NUMBER and MONTH column, I would add a DATE column using real date format (e.g. 2012-06-01)

2. add a measure:

Difference =
VAR Date1 = CALCULATE( MIN('Table'[Date]);ALLSELECTED('Table'))
VAR Date2 = CALCULATE( MAX('Table'[Date]);ALLSELECTED('Table'))
VAR Eearlier = LOOKUPVALUE('Table'[Value];'Table'[Date];Date1)
VAR Later = LOOKUPVALUE('Table'[Value];'Table'[Date];Date2)
 
RETURN(
IF(Eearlier=Later;"No Diff";
IF(Eearlier>Later;"Decreased";"Increased")))
 
 
Anonymous
Not applicable

Hi Cynwaa,

 

Thanks for your reply. Still  getting the below error "Can't load the data for the visual".

 

Regards,

Suresh.

 

 

Hi @Anonymous 

Attached sample file for your reference.It seems sreenathv's workaround is work for you.

Regards,

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

Step 1: Add a calculated column "MonthNumber"

 

 

MonthNumber = SWITCH([Month],
"Jan", 1,
"Feb", 2,
"Mar", 3,
"Apri", 4,
"May", 5,
"Jun", 6,
"Jul", 7,
"Aug", 8,
"Sep", 9,
"Oct", 10,
"Nov", 11,
"Dec", 12,
0
)

Define 4 measures (Not all of them are necessary. You can directly write the final measure by combining the formula into one.

 

 

Measure 1: Initial Figure

 

InitialFigure =
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( Table1, Table1[MonthNumber] = MIN ( Table1[MonthNumber] ) )
)

Measure 2: Final Figure

 

 

FinalFigure =
CALCULATE (
    SUM ( Table1[Value] ),
    FILTER ( Table1, Table1[MonthNumber] = MAX ( Table1[MonthNumber] ) )
)

Measure 3: Difference

 

 

 

Difference = [FinalFigure] - [InitialFigure]

Measure 4: Trend

 

 

Trend = if([Difference]<0,"Decrease",IF([Difference]=0,"No Change","Increased"))

 

 

Now based on your month selection, these measures will give you the results.

 

Disclaimer: In the SWITCH() function, I have assigned 1 for January, 2 for February and so on... If you are following a financial year calendar like Apr to Mar, then you will have to assign 1 for Apr, 2 May, etc... and 10 for Jan, 11 for Feb, and 12 for Mar. Only then the beginning and ending period will be calculated correctly.

vanessafvg
Super User
Super User

@Anonymous  are you looking at the min and max within one year or more than one year?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.