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.
Hello,
I'm trying to get last month's total (which is December 2022) for Category = Apple with "PREVIOUSMONTH" function but it does not work.
Current formula that doesnt work:
Solved! Go to Solution.
Hi @cherrypbi ,
Please try below steps:
1. create a measure with below dax formula
Measure =
VAR cur_date =
TODAY ()
VAR _total =
CALCULATE (
SUM ( 'Table'[Revenue] ),
FILTER (
ALL ( 'Table' ),
'Table'[Category] = "Apple"
&& DATEDIFF ( 'Table'[BillingMonth], TODAY (), MONTH ) = 1
)
)
RETURN
_total
2. add a card visual with measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Create a Calendar Table with calculated column formulas for year, Month name and Month number. Sort the Month name by the Month number. Create a relationship (Many to One and Single) from the Billing Month column to the Date column of the Calendar Table. To your visual, drag year and month from the Calendar Table and Category from the RevenueTable. Write these measures
Rev = SUM ('RevenueTable'[Revenue] )
Rev in previous month = calculate([Rev],previousmonth(Calendar[date]))
Hope this helps.
Hi @cherrypbi ,
Please try below steps:
1. create a measure with below dax formula
Measure =
VAR cur_date =
TODAY ()
VAR _total =
CALCULATE (
SUM ( 'Table'[Revenue] ),
FILTER (
ALL ( 'Table' ),
'Table'[Category] = "Apple"
&& DATEDIFF ( 'Table'[BillingMonth], TODAY (), MONTH ) = 1
)
)
RETURN
_total
2. add a card visual with measure
Please refer the attached .pbix file.
Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@cherrypbi, try this
Revenue PM = CALCULATE(
SUM('RevenueTable'[Revenue]),
'RevenueTable'[Category] = "Apple",
PREVIOUSMONTH(LASTDATE('RevenueTable'[BillingMonth])),
All('RevenueTable'[BillingMonth])
)
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |