I have the following expression in Excel that works fine.
=CUBESET("ThisWorkbookDataModel",
"TopCount(
[ProductBV].[Product Name].Children,10,
sum(
(
[Calendar].[Week Ending].[All].[1/6/2013]:[Calendar].[Week Ending].[All].["&TEXT($E$2,"m/d/yyyy")&"],
[ProductBV].[Moderation Status (ALL)].[All].["&$E$3&"]
),
[Measures].[Product Review Count]
)
)",
"Top 10 to date")
The Product Review Count measure using the following DAX formula.
Product Review Count:=COUNTROWS(ProductBV)
However, when I change the DAX measure to one that utilizes an AVERAGE function (Product Avg Review), the CUBESET function does not work correctly. It still has the correct number of items in the CUBESET, but when I use CUBERANKEDMEMBER(1-10), it does not show me the top 10 Products by Average Rating.
Product Avg Review:=AVERAGE(ProductBV[Rating])
'Not working correctly' expression below:
=CUBESET("ThisWorkbookDataModel",
"TopCount(
[ProductBV].[Product Name].Children,10,
sum(
(
[Calendar].[Week Ending].[All].[1/6/2013]:[Calendar].[Week Ending].[All].["&TEXT($E$2,"m/d/yyyy")&"],
[ProductBV].[Moderation Status (ALL)].[All].["&$E$3&"]
),
[Measures].[Product Avg Review]
)
)",
"Top 10 to date")
All in all, my data is very simple. I have one data table connected to a calendar table that contains my product name, rating, date and review status.
The within my dashboard, my date ($E$2) and the review status ($E$3) can be changed by the user via a dropdown.
+-----------------+-------------------+------------+----------------+
| Submission Date | Moderation Status | Product ID | Overall Rating |
+-----------------+-------------------+------------+----------------+
| 10/23/2016 | APPROVED | Product 1 | 5 |
| 10/23/2016 | APPROVED | Product 2 | 5 |
| 10/23/2016 | APPROVED | Product 3 | 5 |
| 10/23/2016 | REJECTED | Product 3 | 3 |
| 10/23/2016 | REJECTED | Product 4 | 3 |
+-----------------+-------------------+------------+----------------+
Can anyone tell me why this is happening and how to fix it?
This produces a set
CUBESET
.A set has a count so I can appreciate that
COUNTROWS
will function correctly.If you feed a set of members into
AVERAGE
which measure does it average over? This seems to be non-determinant ?Can you feed the set returned by
ProductBV[Rating]
into a subsequent cube function that specifies the measure you'd like to have the average of?When I saw your question I wondered why you were using Excel formulas and controls to create a dashboard if you had you model in PowerPivot. PowerPivot lets you analyze and visualize data in a more robust and reliable way.
Your initial approach is very complex and it is hard to mantain taking in account that:
This is the Dashboard I'd build using Pivot Tables conected to your PowerPivot model.
DOWNLOAD THE EXCEL FILE HERE
To build this dashboard I used four DAX measures:
With measures working you can create a two Pivot Tables, one for showing positive movers and other one to show negative movers.
In
Rows
pane addProduct Name
, inValues
addLast Week
,This Week
andPositive Movement
orNegative Movement
(according to the Pivot Table you are building) measures.Once you have the table built you have have to get the TOP X
Product Names
.In each Pivot Table click the Row tag icon filter (The below settings are for Positive Movers Pivot Table):
And use these settings:
Change
Positive Movement
forNegative Movement
when you are filtering to get the Top 5Product Names
in the Negative Movement table.While you can get the Top 5 product names purely in DAX, I think it is better to use the Pivot Table filter option, leaving it dynamic to any number of top products (what could be a new requeriment in the future) without the need to modify the underlying DAX.
Then you just need to add Conditional Formats and you are done.
Let me know if this helps.