The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi guys,
I'm trying to calculate the difference of the value first day and the last the of the month.
Example:
day - value
01/01/2022 - 1
05/01/2022 - 2
20/01/2022 - 5
29/01/2022 - 5
03/02/2022 - 5
13/02/2022 - 3
17/02/2022 - 3
28/02/2022 - 5
The first month is January, it started with 1 in 01/01/2022 and ended with 5 in 28/01/2022, the difference between them is 4.
And the following month is 0, because it started with 5 and ended with 5.
How can I calculate it for ALL months in my database?
Solved! Go to Solution.
To add as variable |
var mindateindex=calculate(MIN(Index),('# Pagas Recebidas'[Data])=Mindate) |
var maxdateindex=calculate(Index),max('# Pagas Recebidas'[Data])Maxdate) |
change thses 2 lines |
var compteurmini=calculate(max('# Pagas Recebidas'[Saldo]),'# Pagas Recebidas'[Data]=mindate&&Index=mindateindex) |
var compteurmaxi=calculate(max('# Pagas Recebidas'[Saldo]),'# Pagas Recebidas'[Data]=maxdate&&index=maxdateindex) |
It doesn't work
It's probably summing it all, I need the last of the last value.
Yes for sure it is for this. Do you have the time with the date because it taking the minuimum date and if you have more than 1 record at the same date it will not work
Can it be solved?
Does you Date format dis a date Hour?
No, only "date"
Esxcept the date do you have an index or another column you could use to identify the first record from a same date ?
Nothin, but I can create a index column.
Yes could be usefull because Pwbi cannot define the mninimum value.
keep me in touch
I created a column called "index", starting in 0.
To add as variable |
var mindateindex=calculate(MIN(Index),('# Pagas Recebidas'[Data])=Mindate) |
var maxdateindex=calculate(Index),max('# Pagas Recebidas'[Data])Maxdate) |
change thses 2 lines |
var compteurmini=calculate(max('# Pagas Recebidas'[Saldo]),'# Pagas Recebidas'[Data]=mindate&&Index=mindateindex) |
var compteurmaxi=calculate(max('# Pagas Recebidas'[Saldo]),'# Pagas Recebidas'[Data]=maxdate&&index=maxdateindex) |
Thank-you SO MUCH @Anonymous !!!
Welcome
Enjoy Dax 🙂
i
Try this
@Tahech , You can use firstnonblankvalue and lastnonblankvalue
calculate(firstnonblankvalue ('DAte'[DAte], sum(Table[Value]))
or
calculate(firstnonblankvalue ('DAte'[DAte], sum(Table[Value]), allexcept(Table, 'Date'[Month Year]) )
https://www.linkedin.com/pulse/five-recent-power-bi-functions-you-should-use-more-often-amit-chandak
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
80 | |
78 | |
44 | |
37 |
User | Count |
---|---|
157 | |
112 | |
64 | |
60 | |
54 |