The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Good Day!
Can anyone suggest how to calculate the difference of the Quantity of the two given months? differen
Solved! Go to Solution.
Hi @amontemayor ,
According to your description, here's my solution.
1.Create a month number column, because the month column in text compared by alphabetical instead of real month.
If you have a date column in the table, simply create a calculated column.
MonthNum = MONTH([Date])
If not, a calculated column like this instead:
MonthNum=SWITCH([MonthName],
"January",1,
"February",2,
"March",3,
"April",4
.......
2.Create a measure.
Diff =
VAR _Min =
MAXX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Item Description] = MAX ( 'Table'[Item Description] )
&& 'Table'[MonthNum] = MINX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
),
'Table'[Quantity]
)
VAR _Max =
MAXX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Item Description] = MAX ( 'Table'[Item Description] )
&& 'Table'[MonthNum] = MAXX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
),
'Table'[Quantity]
)
RETURN
_Max - _Min
Then get the difference of selected two month. The result is quantity of big month minus quantity of small month. You can either put it in the matrix or a seperate table visual with the Item Description column.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @amontemayor ,
According to your description, here's my solution.
1.Create a month number column, because the month column in text compared by alphabetical instead of real month.
If you have a date column in the table, simply create a calculated column.
MonthNum = MONTH([Date])
If not, a calculated column like this instead:
MonthNum=SWITCH([MonthName],
"January",1,
"February",2,
"March",3,
"April",4
.......
2.Create a measure.
Diff =
VAR _Min =
MAXX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Item Description] = MAX ( 'Table'[Item Description] )
&& 'Table'[MonthNum] = MINX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
),
'Table'[Quantity]
)
VAR _Max =
MAXX (
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[Item Description] = MAX ( 'Table'[Item Description] )
&& 'Table'[MonthNum] = MAXX ( ALLSELECTED ( 'Table' ), 'Table'[MonthNum] )
),
'Table'[Quantity]
)
RETURN
_Max - _Min
Then get the difference of selected two month. The result is quantity of big month minus quantity of small month. You can either put it in the matrix or a seperate table visual with the Item Description column.
I attach my sample below for your reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.