Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

How to calculate cumulative wow values

ItemWeekScoreResponses
155154
155256
155368
155432
2551620
2552910
2553523
2554911
3551623
3552833
3553656
355498

 

 

I have a dataset something like this. 

I want to calculate the WoW change of this data at item level. Let's suppose the items are columns in my output and if I select week 552, I sohuld get a WoW against the current value. 

The catch here is that I want to make it dynamic. If I select two weeks here from the filter pane, I should be able to see the aggregated score(weighted mean) of those two weeks and the WoW should be the score of previous two weeks(aggregated as weighted mean).

Example: If I select week 553 and 554, I should see the wow as (aggregation of week 553 and 554) - (aggregation of week 552 and 551)

I am able to do a simple WoW(one week comparison) using DAX but not able to figure out how to do it if multiple weeks are selected.

I was thinking of doing a countdistinct of the weeks selected in filter and calculate the minimum week(min_week) of the selection. Then, doing a weighted mean from min_week-countdistinct to min_week - 1.

Can somebody help me please

Note: Weeks would always be selected consecutively

 

DAX formula help @Anonymous @Kpower @Anonymous @nepow @dax 

5 REPLIES 5
v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

Just try this formula to get dynamic previous week value

Measure = 
VAR weeks =
    CALCULATE ( COUNTA ( 'Table'[Week] ), ALLSELECTED ( 'Table'[Week] ) )
RETURN
    CALCULATE (
        SUM ( 'Table'[Score] ),
        FILTER (
            ALL ( 'Table'[Week] ),
            CONTAINS ( VALUES ( 'Table'[Week] ), 'Table'[Week], 'Table'[Week] + weeks )
        )
    )

Result:

If selected 552, it will return data in week 551 of each Item.3.JPG

and if selected 553 and 554, it will return data in 551 and 552 of each item.

4.JPG

Then you could use it for other calculation.

 

and here is sample pbix, please try it.

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi  @v-lili6-msft,

Thank you for replying.

A question here, instead of a simple sum, can I do a SUMX as I need weighted mean of the score and responses.

In the calculate tab, can I write SUMX(Score*responses)/sum(responses)

Can this be done?

 

Regards,

 

 

hi, @Anonymous 

Yes, you could try it.

If you still have the problem, please share your expected output as below:

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

hi @v-lili6-msft ,

 

Thanks for your reply.

I will go about explaining my problem once again

 

My data is in this format as below:

 

ItemWeekDriverScoreResp
1551D0698
1551D16.87189
1551D26.6763
1551D35.370
1552D06.92182
1552D17.24133
1552D24.5749
1552D36.2570
3551D07.8196
3551D17.3277
3551D24.97105
3551D35.07161
3552D05.31112
3552D111.370
3552D25.8342
3552D35.55133
4551D04.470
4551D15.0491
4551D28.27469
4551D33.170
4552D03.8649
4552D11535
4552D28.71133
4552D36.2149
7551D08.63119
7551D110.897
7551D24.5749
7551D310.6935
7552D0698
7552D16.87189
7552D26.6763
7552D35.370

 

I want  to calculate the WoW values of the item at item level.

The values should be in a crosstab as below:

 

itemD0D0 - WoWD1D1 -WoWD2D2 - WoWD3D3 - WoW
19 8 8 8 
39 9 8 9 
48 9 9 9 
77 10 9 10 

 

If I select week 552 from the filter, then column D0,D1,D2,D3 in table 2 should show the weighted sum of score and responses and the D0-WoW, D1-WoW, D2-WoW and D3-WoW columns should show the weighted sum of week 551.

What I want is that if I select week 553 and 554, then I should get the WoW column to show the weighted mean of 551 and 552. My data is for 52 weeks. Similarly, selecting 3 consecutive weeks should give me the weighted mean of previous 3 weeks corresponding to the item and driver(D0,D1,D2,D3) and so on.

 

Weighted mean is calculated as: sumx(table, score*response)/sum(response)

 

Appreciate your help!!

 

Regards,

Anonymous
Not applicable

Also, another follow-up question, do all these features work in v2.8?


@Anonymous wrote:

Hi  @v-lili6-msft,

Thank you for replying.

A question here, instead of a simple sum, can I do a SUMX as I need weighted mean of the score and responses.

In the calculate tab, can I write SUMX(Score*responses)/sum(responses)

Can this be done?

 

Regards,

 

 


 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.