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:
Related
i'm new in power bi and i need some help.
i need to calculate total sold product between two dates, e.g. from 5 Feb 2021 to 5 apr 2021, i cant find any solution.
Assume you have sales table with two column Date and Amount. Now you can create your measure as below-
total_sold =
CALCULATE(
SUM(sales[amount]),
DATESBETWEEN(
sales[date],
start_date,
end_date
)
)
Create a card or table and drag your no. of products sold column to the card, and use the filter on the date column to get the total no. of products sold in the time period.
Note:- Please be a little more specific and descriptive the next time.
I am trying to find the Previous year sales for the same week in Power BI.I dont have any date column.
I have two table one is FACT Indicators table as shown below:
and one sales table( Fact Sales table):
I want to create one calculated field namely(Sales Previous Year) to show the previous year sales for the same week .
In 'Fact Indicators' table 'PY 52 week flag' filed shows if this week id is Previous year or not.
Week column shows the week number from 1 to 52 weeks .
Week Id shows the unique number per Market key.
'Market_Week Id Key' is the common joining key between FACT Indicators table and Fact Sales table
Please help me to find the formula for calculated field.I dont have the date field in my raw data
Every time you deal with anything related to dates, you will need to add what we call a date dimension. It will save you tons of headaches. Once you have it in you will be able to hook it into the creation of the calculated filed.
you can google power bi or ssas date dimension and find tons of information on it.
Yeah! I guess SQL Technical team can be a tough crowd.... Well! In this case, I would recommend bringing the Year into FactSales Table from Fact Indicator . You have two options here with physical relationship set up between Market Week Id Key in both tables you can build a calc column with
Year = CALCULATE(VALUES(FactIndicators[Year]))
or without relationship use LOOKUPVALUE on WeekId
Year = LOOKUPVALUE(FactIndicators[Year], FactIndicators[WeekId], FactSales[WeekId])
Sales Last Year calc colum :
SalesLastYear =
CALCULATE (
SUM(FactSales[SalesThisYear] ),
TOPN(1,
FILTER(
FactSales,
FactSales[Year] < EARLIER(FactSales[Year])
&& FactSales[Key] < EARLIER(FactSales[Key])
)
)
)
I am fairly new to PowerBI DAX and I want to filter out the top 20 product ids in a measure.
I came up with this formula but it does not seem to be working and I was hoping to get some help here.
$ Amount Parcel =
CALCULATE(
SUM(Data[$ Amount Parcel]),
FILTER (Data, NOT (Data[idProduct], SUM(Data[NetSales])) IN TOPN(20, SUMMARIZE(Data, Data[idProduct], "NetSales", SUM(Data[NetSales]))))
)
I want to show sales per PID for all products except for our 20 best sellers.
Thank you !!
I would suggest an easier approach adding a dimension column.
First of all, you need to have Product dimension table separated from Sales fact table. Make sure to create one-to-many relationship between Product and Sales with "Single" cross filter direction.
Then you can create a calculated column on Product table, which can be used to filter out top selling products.
Sales Rank = RANKX('Product', CALCULATE(SUM(Sales[SalesAmount])))
Now drag and drop Sales Rank field into the Filters pane of your visualization, and set the filter condition so that top selling products will not be shown.
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
I have a simple Power BI table that looks as follows:
I have two tables. A Date table and an Invoice table with a field representing invoice amounts. This is a 1-M relationship on Invoice.InvoiceDate.
The second column is simply a measure for the sum of invoices. The third and fourth columns are measures using ParallelPeriod to sum invoices for 12 months prior and 24 months prior. Even though these numbers are correct, I'm not entirely certain I know what's actually going on.
The measure for the 12-month parallel period looks like this:
Sum Invoice Amount 12 Months Ago =
CALCULATE (
SUM ( FactCustomerTransaction[InvoiceAmountDollars] ),
PARALLELPERIOD ( 'Date'[Date], -12, MONTH )
)
Here is what I think is happening. When the sum is calculated for say 2015-Feb, all values for that month are retrieved in the invoice (many side) table and summed to generate the "Sum Invoice Amount". The sames dates, minus 12 months, in the Date table, are retrieved and the same sum is generated for those range of dates for 'Sum Invoice Amount 12 Months Ago'. And then the same process for 24 months ago.
This works because of the 1-M relationship between Date and Invoice. Is this correct?
For 2015-Feb row, assuming the Year and Month Name column is on your 'Date' table, your filter context is 'Date'[Year and Month Name] = "2015-Feb". This filter corresponds to the dates 2015-02-01 through 2015-02-28 in your 'Date'[Date] column and that filtering propagates across the relationship to return only the rows in FactCustomerTransaction table where InvoiceDate is one of those dates and then sums the amounts corresponding to only those rows.
When you add PARALLELPERIOD, it works the same way except that after matching the dates 2015-02-01 through 2015-02-28 corresponding to 'Date'[Year and Month Name] = "2015-Feb", it shifts those dates back by 12 months and then propagates those shifted dates across the relationship.