Forum Discussion
Subtract values based on specific criteria
- 8 years ago
Hi Anonymous,
Please check out the demo in the attachment.
1. Select these two columns with "CTRL";
2. Pivot.
Best Regards,
Dale
- Anonymous8 years ago
v-jiascu-msft Thank you! It makes a lot more sense seeing what you did. Also, I think I was on the right track but the column had a lot of null values. That is what was causing the error. I duplicated the whole table, removed the columns I didn't need, filtered out null, then pivoted. Unfortunatley, I'm using DirectQuery and it's telling me that Pivot isn't compatible. So, at least this gets me a little closer because the data looks correct in that I know how I can manipulate it to start extracting what I need from it, like the times. I think I could do the same for BatchCount too. I'll just have to switch everything over to Import and get my gateway setup, and I should be on the right track. Thank you!
I am having similar trouble as a new BI user. I'm trying to calculate session length that is dependent on the variables "action" and "user" or "ip address" to capture distinct sessions. I've tried a few different things but am not having much luck.
Based on this sample data (below) I'd expect that session length calc would result in the following results:
Expected Results:
| Date | user | Session Length |
| 1/1/2022 | user1 | 60 mins |
| 1/1/2022 | user2 | 120 mins |
| 1/2/2022 | user1 | 60 mins |
| 1/2/2022 | user2 | 120 mins |
Sample data
| Username | Time | Action | IP Address | Date Created |
| user1 | 1/1/2022 9:15 | Logout | 123.45.678 | 1/1/2022 |
| user1 | 1/1/2022 8:45 | download | 123.45.678 | 1/1/2022 |
| user1 | 1/1/2022 8:25 | download | 123.45.678 | 1/1/2022 |
| user1 | 1/1/2022 8:20 | download | 123.45.678 | 1/1/2022 |
| user1 | 1/1/2022 8:15 | Login | 123.45.678 | 1/1/2022 |
| user 2 | 1/1/2022 15:15 | Logout | 245.543.123 | 1/1/2022 |
| user 2 | 1/1/2022 13:55 | download | 245.543.123 | 1/1/2022 |
| user 2 | 1/1/2022 13:25 | download | 245.543.123 | 1/1/2022 |
| user 2 | 1/1/2022 13:20 | download | 245.543.123 | 1/1/2022 |
| user 2 | 1/1/2022 13:15 | Login | 245.543.123 | 1/1/2022 |
| user1 | 1/2/2022 9:15 | Logout | 123.45.678 | 1/2/2022 |
| user1 | 1/2/2022 8:45 | download | 123.45.678 | 1/2/2022 |
| user1 | 1/2/2022 8:25 | download | 123.45.678 | 1/2/2022 |
| user1 | 1/2/2022 8:20 | download | 123.45.678 | 1/2/2022 |
| user1 | 1/2/2022 8:15 | Login | 123.45.678 | 1/2/2022 |
| user 2 | 1/2/2022 15:15 | Logout | 245.543.123 | 1/2/2022 |
| user 2 | 1/2/2022 13:55 | download | 245.543.123 | 1/2/2022 |
| user 2 | 1/2/2022 13:25 | download | 245.543.123 | 1/2/2022 |
| user 2 | 1/2/2022 13:20 | download | 245.543.123 | 1/2/2022 |
| user 2 | 1/2/2022 13:15 | Login | 245.543.123 | 1/2/2022 |
need to isolate distinct users/sessions and then subtract time where action = logout vs login.
greatly appreciate any ideas.