Search code examples
sql-servercomparisonpowerbivisualization

How Would I Be Able to Compare Data Between 2 Dates in PowerBI?


I'm trying to show a comparison between 2 dates in a SQL table in PowerBI. Specifically, I'm trying to show a comparison between the date someone started training and the date someone finished training.

The fields in the view are DateApproved, DateCreated, FirstName, LastName, Name (name of the training), Goal (description of the training), and GoalCategoryId (numerical Primary Key), and the relationship I'm trying to show is a comparison between who has started training and finished versus who has started training but hasn't finished.

I've experimented with adding in the different fields and altering what visualizations to use, but I just can't get the data to present itself right.

Would there be a way to add a column or two to show this comparison? If it's relevant information, I'm getting my data from SQL Server via DirectQuery.


Solution

  • I realized the error I was making in doing this. I had made the view in SQL without establishing two obviously related values. What I did to show this relationship was code a CASE statement in the view that would mark all dates listed as NULL as "Incomplete" and all not null listed as "Complete". Then I put this in its own column. My code is as follows:

    CASE
    WHEN DateApproved IS NOT NULL
    THEN 'Completed'
    ELSE 'Incomplete'
    END AS CompletionStatus
    

    This made it to where I could query the table into PowerBI, use GoalCategoryId as the Count, and show a perfect, graphical relationship between which goals were complete and incomplete. Sometimes, apparently, the problem is in the SQL and not how PowerBI reads it.