Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi Guys,
I have a table that contains a report date and values for that date. The dates are unique in the table.
In the visual I would like to highlight the differences of Amount 1 (Report date-Prev. Report Date) and Amount 2 (Report date-Prev. Report Date) .
I was successful in determining the previous report date, however, I can't determin the previous amounts (or at least the difference)
Actually the difference would also work.
Table1:
Report Date | Amount1 | Amount2 | Prev. Report Date | Prev. Amount1 | Prev. Amount2 |
17.03.2021 | 50 | 154 | 15.03.2021 | 24 | 148 |
15.03.2021 | 24 | 148 | 14.03.2021 | 185 | 23 |
14.03.2021 | 185 | 23 | 20.02.2021 | 33 | 885 |
20.02.2021 | 33 | 885 |
Any idea how I can add this information to my table using DAX? Or a Measure?
Thanks in advance.
Solved! Go to Solution.
Hi,
pls see below:
PrevAmount =
VAR _selDate = SELECTEDVALUE(DimDate[Date])
VAR _maxDate = CALCULATE(LASTNONBLANK(DimDate[Date], CALCULATE(SUM('Table'[Amount1]))), FILTER(ALLSELECTED(DimDate), [Date] < _selDate))
RETURN
IF(NOT(ISBLANK(SUM('Table'[Amount1]))),
CALCULATE(SUM('Table'[Amount1]), FILTER(ALLSELECTED(DimDate),DimDate[Date] = _maxDate)), BLANK())
Kind regards, Steve.
Proud to be a Super User!
Awesome Keyboard Shortcusts in Power BI, thumbs up if you like the article
My Community Blog Articles (check them out!)
My Blog - Power M code to automatically detect column types -
How to create test data using DAX!
Hi,
pls see below:
PrevAmount =
VAR _selDate = SELECTEDVALUE(DimDate[Date])
VAR _maxDate = CALCULATE(LASTNONBLANK(DimDate[Date], CALCULATE(SUM('Table'[Amount1]))), FILTER(ALLSELECTED(DimDate), [Date] < _selDate))
RETURN
IF(NOT(ISBLANK(SUM('Table'[Amount1]))),
CALCULATE(SUM('Table'[Amount1]), FILTER(ALLSELECTED(DimDate),DimDate[Date] = _maxDate)), BLANK())
Kind regards, Steve.
Proud to be a Super User!
Awesome Keyboard Shortcusts in Power BI, thumbs up if you like the article
My Community Blog Articles (check them out!)
My Blog - Power M code to automatically detect column types -
How to create test data using DAX!
Hey Steve,
thanks a lot. Appreciate your support.
Hans
@TheHans , Try a measure like
calculate(sum(Table[Amount1]), filter(allselected(Table), Table[Date] =calculate(max(Table[Date]),filter(allselected(table), [Date] <max([Date])))))
Hi Amit,
thanks for the quick reply. I get as a result 24 for every row.
Is there a way to add new columns as in my example "Prev. Amount1" and "Prev. Amount1" which is calculated out of the existing data in the table?
Basically the result of this should look like in the sample table above.
Hans
User | Count |
---|---|
47 | |
26 | |
21 | |
17 | |
15 |
User | Count |
---|---|
53 | |
34 | |
17 | |
17 | |
15 |