Forum Discussion

hatchda's avatar
hatchda
Frequent Visitor
5 years ago

Display Weekly Total based on a report that is generated daily

I have report which is generated daily to CSV and then imported into SQL every day. The report has no date timestamp, so when the CSV is imported into SQL, it adds a datestamp column.

 

I want to show display the total count of servers for every Sunday.

01/01/2021: VMReport1

TimeStampVMName
01/01/2021Machine1

 

01/02/2021: VMReport2

TimeStampVMName
01/02/2021Machine1
01/02/2021Machine2

.

.

.

01/07/2021: VMReport7 has 23 VMNames

 

I want to show the total of VMNames for every 7th day of the week. For the example above, it should be 23. The Date Hierarchy in the Field section doesn't have Week as an option.

5 Replies

  • hatchda you want to show the count of Sunday or Thursday? You have two different weekdays in your post.

    • hatchda's avatar
      hatchda
      Frequent Visitor

      I would like to show the count for every Sunday because I would like have a graph that shows the Total Servers for each week. 

       

      Thanks,

      David

  • hatchda create a date table in your model and you should have a column in this called weekday, there are many posts on how to add one, here is one of my post, and then add a measure

     

    Server Count on Sunday = 
    CALCULATE ( COUNTROWS ( Table ), KEEPFILTERS ( DateTable[Weekday]  = "Sunday" ) ) 

     

    On the bar chart, use date on the x-axis from the date table and above measure, it should work.

     

    Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi hatchda ,

     

    According to my understanding, you want to calculate the distinct count of Machine of each Sunday,right?

     

    You could firstly add a Week column and then use the following formula to calculate:

    Week =
    WEEKNUM ( [Date], 2 )
    Count Column=
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[VMReport] ),
        FILTER ( 'Table', 'Table'[Week] = EARLIER ( 'Table'[Week] ) )
    )

    Or 

    Count Measure =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[VMReport] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Week] = MAX ( 'Table'[Week] ) )
    )

    The final output is shown below:

     

    Please kindly take a look at the pbix file here.

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi hatchda ,

     

    Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Thank you.

     

    Best Regards,
    Eyelyn Qin