Power BI Desktop - A card that shows most recent invoice above $1Million - powerbi

I am trying to create a card that shows the most recent invoice above $1Million. Right now, I have a card that shows the most recent invoice, but I cannot find a way to only display the most recent above $1million.
Most Recent Invoice = CALCULATE(max(table1[Invoice_Line_Amount_USD]), lastdate(table1[Invoice_Posting_Date]))
EDIT: let me rephrase my question(s)/
I am wanting to show a table that has today's invoice only displayed and everyday when it is refreshed it will either show the invoices that were posted that day only or it will be blank (no invoices posted). I am wanting to have a card that shows the current days highest invoice about $1million and another card that shows the sum of the number of invoices for the current day. Then, I am going to create an alert that will notify me when an invoice about $1million is posted. The reason why I would like to display the highest invoice for that day on one of the cards is because when I receive that email it will tell me the amount of the highest invoice for that day (before I only had the sum of all of the invoices, which sent me an alert with only that amount).

Try this
Most Recent Invoice GTE 1M USD = CALCULATE(
lastdate(table1[Invoice_Posting_Date])
,
Filter( table1, table1[Invoice_Line_Amount_USD] >= 1000000)
)
If lastdate is not working correctly, try
Max ( table1[Invoice_Posting_Date])
The formula I did was filter the table for our conditions, which is >= 1M and the use the data to get the last date.

I reworked and did it two ways
Let us say you have data as Table with Data
I created measures and calculated columns as Table Columns
Is Today = IF(Table1[Invoice_Posting_Date] = TODAY (), 1, 0 )
Invoice Line Amount USD - Today = CALCULATE( SUM(Table1[Invoice_Line_Amount_USD]), FILTER(Table1, [Is Today] = 1 ))
Count Is Today GTE 1M = SUM( Table1[Is Today] )
Count Is Today = COUNTROWS( FILTER(Table1, [Is Today] = 1 ))
Overall output as
Overall output
using filters plus required measure approach

Related

Power BI - MoM % is showing total of 0% when I would like it to show the most recent months MoM %

I am attempting to create a card within Power BI that calculates a MoM change in a value. I want it to show the most recent month to date vs the previous month of the data. However, it looks like it is calculating the total. The measure I have looks like it would be calculating this correctly, but it is not being displayed in the card correctly.
The measure:
TTL BELOW FLR MoM% =
IF(
ISFILTERED('IA_TCALENDAR_DATES'[CALENDAR_D]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy or primary date column."),
VAR __CURR_MONTH =
CALCULATE(
[TTL BELOW FLR],
DATEADD('IA_TCALENDAR_DATES'[CALENDAR_D], 0, MONTH)
)
VAR __PREV_MONTH =
CALCULATE(
[TTL BELOW FLR],
DATEADD('IA_TCALENDAR_DATES'[CALENDAR_D], -1, MONTH)
)
RETURN
DIVIDE(__CURR_MONTH - __PREV_MONTH, __PREV_MONTH)
)
Calc is 0
I am expecting it to show the - 83% (in the attached picture) as the most recent month in the dashboard is filtered to February 2023.
The card (and Total row) shows the MOM% without an applied evaluation context except for page/report level filters.
To get a different result, either constrain your DAX to use the maximum reported date (or today) as an upper bound, or set a relative date filter on your visualization.

Dax measure that counts number of occurrence

I want to create measure Invoice Counter that shows number of invoices per customer. This measure must reflect slicer in the page.
If in year slicer is selected year = 2022, measure should reflex this.
Sorry I don't paste my test code here, it was nonsense so far.
Thanks for help.
Your modelling approach is a little awkward: Your table shows an Invoice Counter of 3 for the single invoice 11 in 2022 for "jack", and the sum of Invoice Counter is 14, although there are 6 different invoices only. This is at least confusing ...
Your Invoice counter measure should aggregate invoice like this:
Invoice Counter =
CALCULATE(
COUNT('Table'[invoice]),
ALLEXCEPT('Table', 'Table'[customer])
)
but then you can't filter it by invoice again, because that will undo the above aggregation. Just put customer, year and Invoice Counter in one table and of cause you can filter that table by year, if you like:

Line chart Power BI - different value for different period of time

I am using power BI and I would like to create a line chart which contains values from two tables (sales history and sales prediction). So for the past 12 months, the line should reprensent the sales history and for the next 6 months, the line reprensents sales prediction. Here is what the data looks like, lets say we are in June 2021:
I know there is a way to do it in DAX but I don't know how to do it by myself. Thanks a lot in advance for your help !
You can achieve this by
Delete any relationship between Calendar and the other two tables if there is any, as we are going to use DATESBETWEEN function to calculate
Create two metric like below, you might need to adjust the column names as per your project
Sales History Amount = IF('CALENDAR'[Date] <= TODAY(), CALCULATE(SUM('Sales History'[Amount]), DATESBETWEEN('Sales History'[Date], MIN('CALENDAR'[Date] ), MAX('CALENDAR'[Date]))), BLANK())
Sales Prediction Amount = IF('CALENDAR'[Date] >= TODAY(), CALCULATE(SUM('Sales Prediction'[Amount]), DATESBETWEEN('Sales Prediction'[Date], MIN('CALENDAR'[Date] ), MAX('CALENDAR'[Date]))), BLANK())
Add these two metrics in the table and use the Date from the Calendar table as X axis.
Format the first metric to solid line, and dash line for the second
Calendar should be linked to your tables.
Prediction Amount =
VAR lastSalesDate = MAX('Sales History'[Date])
VAR currentPredictionAmnt =
CALCULATE(
SUM('Sales Prediction'[Amount])
,KEEPFILTERS('CALENDAR'[Date]>lastSalesDate)
)
RETURN currentPredictionAmnt + SUM()
Sales Amount =
SUM('Sales History'[Amount])

Active users on a given date in a Month in Power BI

I am working to get cumulative distinct count of uids on daily basis. My dataset consists dates and UserIDs active on that date. Example : Say there are 2 uids (235,2354) appeared on date 2022-01-01 and they also appeared on next day with new uid 125 (235,2354,125) on 2022-01-02 At this point i want store cumulative count to be 3 not 5 as (user id 235 and 2354 already appeared on past day ).
My Sample Data looks like as follows:
https://github.com/manish-tripathi/Datasets/blob/main/Sample%20Data.xlsx
enter image description here
and my output should look as follows:
enter image description here
Here's one way that seems to work, using your linked Excel sheet as the data source.
Create a new table:
Table 2 = DISTINCT('Table'[Date])
Add the columns:
MAU = CALCULATE(
DISTINCTCOUNT('Table'[User ID]),
'Table'[Date] <= EARLIER('Table 2'[Date]))
DAU = CALCULATE(DISTINCTCOUNT('Table'[User ID]),
'Table'[Date] = EARLIER('Table 2'[Date]))
Result from your Excel data

Power BI Rolling Average

I've used the new Quick Measures feature of Power BI to build a 3 month rolling average calculation and it's working well. The equation is displayed below. However, when I try to use this metric in a time series visualization, the calculations are displaying three months past the current month, but I'd like for the calculation to stop at the current month.
I've played around with the __DATE_PERIOD variable to no avail. My date filter for the page is set to show all dates in the current months or 12 months prior via a calculated column on the date table.
Is anyone aware of how I can get the visualization to end at the current month?
Average Days to Close Rolling Average =
IF(
ISFILTERED('Date'[Date]),
ERROR("Time intelligence quick measures can only be grouped or filtered by the Power BI-provided date hierarchy."),
VAR __LAST_DATE =
ENDOFMONTH('Date'[Date].[Date])
VAR __DATE_PERIOD =
DATESBETWEEN(
'Date'[Date].[Date],
STARTOFMONTH(DATEADD(__LAST_DATE, -3, MONTH)),
__LAST_DATE
)
RETURN
AVERAGEX(
CALCULATETABLE(
SUMMARIZE(
VALUES('Date'),
'Date'[Date].[Year],
'Date'[Date].[QuarterNo],
'Date'[Date].[Quarter],
'Date'[Date].[MonthNo],
'Date'[Date].[Month]
),
__DATE_PERIOD
),
CALCULATE(
'Closed Opportunities'[Average Days to Close],
ALL('Date'[Date].[Day])
)
)
)
In order to limit what is displayed within your chart, you need to filter the applicable date field so it only displays the dates you desire. In this case, you only want it to include dates <= today.
In order to automatically filter it when it is refreshed, I typically add a custom DAX column to the date table that I can filer on. In this case it would be something along the lines of:
excludeFutureDatesInd = 'Date'[Date] <= TODAY()
You can then add a visual, page, or report filter selecting all dates where [excludeFutureDatesInd] = True.
Not sure if you're still having issues with this, but I'd like to share a hack fix for those landing here. I fixed this issue by filtering on the base data (in your example, this would be "Average Days to Close"). Set a visual-level filter to include only those items where Average Days to Close > 0, and you should get the extra dates cut off the end of the graph.
So long as all of your base data passes through the filter, you should be good.