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
Zarlot531
Helper V
Helper V

Rolling sums, but on a text field...

So I have built the below matrix showing the month lag it takes install orders. I plan to put this in a %-to-total view. 

 

But what really makes sense is to have this in a rolling format. so that, for example, one can see that by 3 months, say, 30% of orders have been installed, not just the % that was installed in month 3. The main problem I see here though is that that the "months" (Lag2) column is actually a text column. Why? Well, "12+" isn't a number, neither is "reversed." Reversed should actually not be rolled up since they never happened. 

 

Is this possible at all? Now that I think about it, I might be able to re-write my case statement at the SQL level to make, say, "3" equal 3 or less. Hmm

 

Rolling3.JPG

2 ACCEPTED SOLUTIONS

Hi @Zarlot531 ,

 

See my PBIX here:

https://1drv.ms/u/s!Ancq8HFZYL_aiIkk9Sw0fCTwRWXgkw?e=Xsixhc

What did I do:

1. Create a calculated column named LagNumerical (based on Lag3 column)

2. Removed error rows from the dataset (rownumbers 621, 1004 and 1768) in Query Editor

3. Created the following measure:

 

Measure = 
VAR selectedLag = SELECTEDVALUE(Sheet1[LagNumerical], 100)
VAR minDate = CALCULATE(MIN(Sheet1[SoldMonth]), REMOVEFILTERS(Sheet1[LagNumerical]))
VAR maxDate = CALCULATE(MAX(Sheet1[SoldMonth]), REMOVEFILTERS(Sheet1[LagNumerical]))
RETURN
CALCULATE(SUM(Sheet1[RMR]), FILTER(ALL(Sheet1), Sheet1[LagNumerical] <= selectedLag && Sheet1[SoldMonth] >= minDate && Sheet1[SoldMonth] <= maxDate))

 

That seemed to have done the trick to have rolling sums of RMR 🙂

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Alright so this bugged me more than I like to admit 😛 However, I finally came up with a fix for that behaviour. To be completely honest, I don't fully understand why this is working and I wasn't able to solve this without a related table, but anyway; it works and it fits your requirements.

Basically what I did was creating a table (dim_NumLag) with values 1-13 and 100 in a single column named 'UniqueLagNums'. Then I created a 1-many relationship between dim_NumLag[UniqueLagNums] and Queri1[LagNumerical] (the calculated column). Then I changed the Matrix visual to use dim_NumLag[UniqueLagNums] as columns and changed the measure like this:

 

Measure2 = 
VAR selectedLag = CALCULATE(SELECTEDVALUE(dim_NumLag[UniqueLagNums], 100))
RETURN
CALCULATE(SUM(Sheet1[RMR]), Sheet1[LagNumerical] <= selectedLag, REMOVEFILTERS(dim_NumLag[UniqueLagNums]))

 

Resulting in the following table:

image.png

I have updated my file so you can redownload it if you like 🙂 This was fun! If you don't mind, I might write a blog post about this.

 

Kind regards

Djerro123

-------------------------------

If this answered your question, please mark it as the Solution. This also helps others to find what they are looking for.

Keep those thumbs up coming! 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

24 REPLIES 24

Thanks again. Capture99.JPGI tried this, but just for experimental purposes I did < 5 for "0" (which obviously doesn't make sense but I'm just trying to figure out what the DAX is doing. And so it sums up the entire first 4 but for everything, and not related to year, as seen below. 

I've been playing with the formula some. In the above formula, I don't understand why when I change <=2 to 1 or 3 or 0 the numbers underneath the 0 in the chart don't change at all. Capture76.JPG

Capture455.JPG

Is it possible to share the PBIX? I feel we are trying to solve problems we (on my advise ;)) created ourselves and we are straying away from the main goal. Alternatively, you can create an cleaned data sample and share that. That way I can play around with the model and see more quickly what is wrong. If you want, you can PM me the link (onedrive or google drive for example).


Kind regards,
Djerro123





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




No worries, I wouldn't have even made it this far without your help. Below is a link to the data I'm using. Only thing I've done in Power BI is the measures we've discussed and a sort/index table to sort the columns, since the columns have "12+" and "Reversed." 

 

https://www.dropbox.com/s/a5ppegph8bbgdik/DataShare.xlsx?dl=0 

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.