Forum Discussion
Only Showing Values in Table That Apply to both Row and Column
- 6 years ago
I created 2 calculated columns to get the visit and spend ranges:
Spend Range = VAR SpendRange = CALCULATE( SUM(Visits[Amount Spent]), ALLEXCEPT(Visits,Visits[User ID]) ) RETURN SWITCH( TRUE(), SpendRange >= 0 && SpendRange <= 1000, "0 - 1K", SpendRange >= 1001 && SpendRange <= 2000, ">1K - 2K", SpendRange >= 2001 && SpendRange <= 3000, ">2K - 3K", SpendRange > 3000, ">3K" ) Visit Range = VAR VisitCount = CALCULATE( COUNTROWS(Visits), ALLEXCEPT(Visits,Visits[User ID]) ) RETURN SWITCH( TRUE(), VisitCount >= 0 && VisitCount <= 3, "0 - 3", VisitCount >= 4 && VisitCount <= 6, "4 - 6", VisitCount >= 7 && VisitCount <= 0, "7 - 9" )Because the Spend Ranges will not sort properly, I created a new table in Power BI to just have the ranges and the sort priority:
There was no need for the Visit ranges since as labeled, alphabetical sort would work. However, if you have visits above 9, you'd need to do the same type of table since 10 would sort before 4 alphabetically.
Then in the model, I related this Range table to my data table.Added a sum measure:
Total Spent = SUM(Visits[Amount Spent])Then dropped the fields in this matrix and told it to sort the Range by the Range Sort field in the Modeling tab.
See Sort By Columns article for specifics on what I did there if you aren't aware of that feature.
If I've not met your goal or you have questions, let me know!
If someone wants to jump in they can. I a may be able to find time to work on it more, but I’m really here to help users with specifics questions. Full projects obviously involves more time and knowledge of the requirements. I hope you can understand that.
Hi edhans ,
I completely get it. My original ask was one of those "this can't be this complicated, can it?" type questions and I even said I thought your solution had it. I'm always so pleased with the time calcs within Power BI so I didn't even assume that it wouldn't be updating the table.
I really appreciate all of your help with this one. I think we might as well put it to bed. I've chatted with a few other data experts within my company today and all of them gave me kind of a blank stare.
Sorry to be unclear initially but the ask did change and I was hoping the solution was just a plug in. Guess not!
Thanks again!