Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello,
I have been trying to figure out this measure for 3 days and have not gotten anywhere. I have a measure created "Total Exceptions Count" has does a countrows('ExceptionsTable') works with no issues. I also have a "Total Exceptions Recent Month" measure to use to calculate the count for most recent date.
I can add it to a table visual with dates (dates table) and gives the total exceptions in the month. I need a measure that gives me prior month exceptions. I cannot use the standard of:
Total Exceptions Count PM = Calculate ( [Total Exceptions], DATEADD ( 'Date' [Date], -1, MONTH ) )
Total Exceptons Count PM2 = Calculate ( [Total Exceptions], PREVIOUSMONTH ( 'Date'[Date] ) )
These two do give the desired output, with the exception DATEADD SUMS the total and PREVOUSMONTH does not give a total. I have another measure finding the "% Month Change Exc Count" which throws the calculation wrong. Example: for 8/31/2021 the "% Month Change Exc Count" is [Total Exceptions Recent Month]-[Total Exceptions Count PM]/[Total Exceptions Count] :661-1,879)/18879 gives 96%. What I want is (661-567)/567 = -17%.
I have also tried the below, but gives no total output like PM2.
Total Exception Count PM =
IF( HASONEVALUE( 'Date'[MonthNumber] ),
CALCULATE( [Total Exception Count] ,
DATEADD( 'Date'[Date], -1, MONTH ) ),
BLANK() )
The green % is what I want to display in a KPI.
Is there a better way to do this. I can't use the "normal" = CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PREVIOUSMONTH('DateTime'[DateKey])) as my [Total Exception Count] is a measure of COUNTROWS(ExceptionTable) and not a column?
Thanks for your help!
Saul
Solved! Go to Solution.
Here's one way to do it (with a similar approach to the measure you already have). I used an existing model to try the approach out. My Recent Month measure is the same but with 0 instead of -1 in the EOMONTH part.
Total Sales Previous Month =
VAR EOMmaxSalesDate =
EOMONTH ( MAXX ( Sales, Sales[SaleDate] ), -1 )
RETURN
CALCULATE (
[Total Sales],
FILTER ( ALL ( 'Date'[MonthEnding] ), 'Date'[MonthEnding] = EOMmaxSalesDate )
)
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Here's one way to do it (with a similar approach to the measure you already have). I used an existing model to try the approach out. My Recent Month measure is the same but with 0 instead of -1 in the EOMONTH part.
Total Sales Previous Month =
VAR EOMmaxSalesDate =
EOMONTH ( MAXX ( Sales, Sales[SaleDate] ), -1 )
RETURN
CALCULATE (
[Total Sales],
FILTER ( ALL ( 'Date'[MonthEnding] ), 'Date'[MonthEnding] = EOMmaxSalesDate )
)
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Thanks Pat,
that worked, even works with time inteligence when selecting slicer dates. I guess what I am seeing now is that your measure is giving the MAXX date and it's using that MAX date -1 to calculate previous month and mine was not. Guessing why that worked, right?
I hope you OK from the concussion from this weekends game (Chiefs).
I appreciate the help!! Good start to the week!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
11 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |