Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
All,
I have the following mesure to extract the last date from a table:
I want to compare the value (number of tickets) of this date with the number of tickets of the penultimate date in the table.
Thx
@Foolke can you share sample data with expected output?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Data:
TicketDate | Responsible Group | INCIDENT | SRQ |
04/12/2019 | Westteam | 253 | 100 |
25/11/2019 | Westteam | 239 | 120 |
example output from excel
Hi @Foolke ,
You can refer to the following steps if they meet for your requirements.
Steps:
1. Enter to query editor and do unpivoted columns on value fields incident SRQ.
2. Create a matrix visual with attribute as row, ticketDate as column.
3. Write a measure formula to use current attribute and date to calculate the dynamic results and use on matrix value field.
Measure =
IF (
ISFILTERED ( 'Sample'[TicketDate] ),
CALCULATE ( SUM ( 'Sample'[Value] ), VALUES ( 'Sample'[Attribute] ) ),
VAR _max =
CALCULATE ( MAX ( 'Sample'[TicketDate] ), VALUES ( 'Sample'[Attribute] ) )
VAR _previous =
CALCULATE (
MAX ( 'Sample'[TicketDate] ),
FILTER ( ALLSELECTED ( 'Sample' ), [TicketDate] < _max ),
VALUES ( 'Sample'[Attribute] )
)
RETURN
CALCULATE (
SUM ( 'Sample'[Value] ),
FILTER ( ALLSELECTED ( 'Sample' ), [TicketDate] = _max ),
VALUES ( 'Sample'[Attribute] )
)
- CALCULATE (
SUM ( 'Sample'[Value] ),
FILTER ( ALLSELECTED ( 'Sample' ), [TicketDate] = _previous ),
VALUES ( 'Sample'[Attribute] )
)
)
4. Modify subtotal -> column total to change display aggregate field name.
Regards,
Xiaoxin Sheng
Thx @v-shex-msft , The unpivot table does a part of the job.
The only remaining challenge is to select the last 2 values from the dates.
Dates are updated every week. I am only interested in the last 2 dates.
Hi @Foolke ,
Do you mean your table contains a lot of records but you only want to display the last two dates? If this is a case, you can add a visual level filter on date fields with 'TopN' mode to choose 'top' 2 dates.
Regards,
Xiaoxin Sheng
Thx @v-shex-msft , we are getting there.
Now I have a last problem.
How can I make sure that the 2 columns are subtracted instead of summing (column a - column b)? If I do this via agregation it doesn't work. See screenshot
HI @Foolke,
I don't think you can achieve this via aggregation features. In my opinion, I'd like to suggest you create a new calculated column to store the result of 'column A'- 'Column B'.
Regards,
Xiaoxin Sheng
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
99 | |
76 | |
64 | |
58 |
User | Count |
---|---|
148 | |
113 | |
97 | |
84 | |
67 |