Forum Discussion

dpwhitey's avatar
dpwhitey
Regular Visitor
4 years ago
Solved

Week on Week Variance, with a 2 week dataset

 

Hello all,

 

New Power BI use., Thanks in advance for any help.

 

I have a report that runs a past 14 day dataset that is refreshed each week. I need to be able to display in Power BI in the above format.

 

My questions are - regarding bins -

1. When I set the number of bins as 2, the bin size is automatically 6.5 days? Why is this not 7 days? When I manually set the bin size at 7 days, it creates 3 bins. Why?

 

 

2. Can I use bins to calculate a variance of bin1 vs bin2? If so how can I do this? I can't seem to find the correct syntax when I search.

 

3. Can I edit the bin name? The bin name defaults to the earliest date, which isn't helpful in the visualisation

 

 

 

I have also tried to create a calculated colum with this formula, to display the week end date.  Is it better to use a column and calculate a variance measure on Week1 vs Week2?  What is the easiest way to add a "Week 1" and "Week 2" label to the first and last 7 days in a dataset? 

 

WeekEndDate =
VAR d =
MAX ( 'Mental Health Caseload'[Case Date] )
RETURN
d
- QUOTIENT ( DATEDIFF ( 'Mental Health Caseload'[Case Date], d, DAY ), 7 ) * 7

 

Thanks

 

Daniel

  • Anonymous's avatar
    Anonymous
    4 years ago

    HI dpwhitey,

    How did you table store the date fields? stored in multiple fields or one field? If you mean multiple date fields, I'd like to suggest you do unpivot columns on them.

    Unpivot columns - Power Query | Microsoft Docs

    Then you can add a calculated field to check unpivoted date values to return the custom tag of these fields (remark them to week 1, week 2) for matrix column filed usages.

    If you are confused about these operations, can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

    How to Get Your Question Answered Quickly  

    Regards,

    Xiaoxin Sheng

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI dpwhitey,

    How did you table store the date fields? stored in multiple fields or one field? If you mean multiple date fields, I'd like to suggest you do unpivot columns on them.

    Unpivot columns - Power Query | Microsoft Docs

    Then you can add a calculated field to check unpivoted date values to return the custom tag of these fields (remark them to week 1, week 2) for matrix column filed usages.

    If you are confused about these operations, can you please share a pbix or some dummy data that keep raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

    How to Get Your Question Answered Quickly  

    Regards,

    Xiaoxin Sheng