March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
I have a table with records including multiple dates per record. One person had multiple transactions on multip[le dates. I have to find the min date, first date of transaction and last date of transaction and the amount withdrawn/deposited on those 2 transactions.
I am open to crreating 2 separate tables saying first transaction and last transaction. or having 1 table with both the information.
When I am using min date funstion its giving me min of the date column and not per record.
Any help is much appreciated
Solved! Go to Solution.
Ok I have no idea what your ideal outcome is... I thought a derived table was the objective, how did it become a workaround?
Use the Relationships tab in PowerBI to create the relationship. EmpID isn't a primary key in the initial table because it has duplicates, but it's unique in the second table so should be fine.
Your requirement is not quite clear for me, based on my understanding, are you looking for something like nested IFs?
minDate = IF ( 'table'[date4] > IF ( IF ( 'table'[date1] > 'table'[date2], 'table'[date2], 'table'[date1] ) > 'table'[date3], 'table'[date3], IF ( 'table'[date1] > 'table'[date2], 'table'[date2], 'table'[date1] ) ), IF ( IF ( 'table'[date1] > 'table'[date2], 'table'[date2], 'table'[date1] ) > 'table'[date3], 'table'[date3], IF ( 'table'[date1] > 'table'[date2], 'table'[date2], 'table'[date1] ) ), 'table'[date4] )
maxDate = IF ( 'table'[date4] < IF ( IF ( 'table'[date1] < 'table'[date2], 'table'[date2], 'table'[date1] ) < 'table'[date3], 'table'[date3], IF ( 'table'[date1] < 'table'[date2], 'table'[date2], 'table'[date1] ) ), IF ( IF ( 'table'[date1] < 'table'[date2], 'table'[date2], 'table'[date1] ) < 'table'[date3], 'table'[date3], IF ( 'table'[date1] < 'table'[date2], 'table'[date2], 'table'[date1] ) ), 'table'[date4] )
Alternatively, you can unpivot the date columns and use MAX and MIN.
Hi,
I have an unpivoted date column table only and when i use Max and Min its calculating the min and max of all records and not per record . but the desired output is the same liek your screen shot.
Can you add a column to the table with something like this formula?
MinDate = CALCULATE(MIN(Table1[Date]), ALL(Table1), Table1[person] = EARLIER(Table1[person]))
MaxDate = CALCULATE(MAX(Table1[Date]), ALL(Table1), Table1[person] = EARLIER(Table1[person]))
getting the following error message:
"A single value for column 'date' in table 'table1' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
Can you paste in your exact formula?
EDIT: Just reread the error, looks like you're making it as a measure. You need to make it as a new Table, not a new Measure.
As a workaround I created a derived table only with Emp Id, firsttransaction date , Last Transaction date.
but I want to pull the dates from this table and amount from the parent table but its not letting me pull any column from parent table. How do I create a relation between the two, as EmpId is Primary key for both the tables
That works..All ypour help is much appreciated!
Ok I have no idea what your ideal outcome is... I thought a derived table was the objective, how did it become a workaround?
Use the Relationships tab in PowerBI to create the relationship. EmpID isn't a primary key in the initial table because it has duplicates, but it's unique in the second table so should be fine.
Actually I was trying to pull all the data fields in one table including min and max dates. But If I do so I am getting duplicates as its pulling all the records.
So the workaround is:Pulling only EmpId, Mindate and Max date in one table. Then Link it to parent table and create reports.
But I could not figure out a way to create a link or relationship between the derived table and the parent table.
My apologies for any confusion , I am very new to POwer BI, trying to work it out.
@rpratibha86 wrote:
When I am using min date funstion its giving me min of the date column and not per record.
The formula will operate over the filter context. If you select a single person, it should give max and min for them. If you select all people, it should give min and max for all people. The correct formula depends on what you are trying to achieve. If you can post samples of your desired output and your table structure, I can give you more guidance.
I am trying to Achineve some thing like this:
If you're set on a new table, you can use SUMMARIZE to create it:
NewTable = SUMMARIZE(Data, Data[Emp ID], "FirstTransactionDate", MIN(Data[Transactiondate]), "LastTransactionDate", MAX(Data[Transactiondate]))
Tried this solution but its not working..still pulling up all the rows.
instead of creating new tables you should try DAX functions FIRSTDATE and LASTDATE.
I was able to pick min and max dates using firstdate and last date, is there way I can pull the corresponsing transaction amount, like the amount on first date and amount on last date
Use the LOOKUPVALUE function. You could use extra clauses in the SUMMARIZE function but it's probably easier to make a new column like:
FirstAmount = LOOKUPVALUE(Data[Amount], Data[Transactiondate], NewTable[FirstTransactionDate])
Similar for LastAmount.
I am getting the following error:
A table of multiple values was supplied where a single value was expected.
Oh wow, I'm not very smart, sorry.
FirstAmount = LOOKUPVALUE(Data[Amount], Data[Transactiondate], NewTable[FirstTransactionDate], Data[Emp ID], NewTable[Emp ID])
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
90 | |
86 | |
83 | |
72 | |
49 |
User | Count |
---|---|
167 | |
149 | |
98 | |
73 | |
57 |