How to implement parameterized measures in Power BI through AtScale

Symptom

In Power BI, parameterized measures are typically created using local tables and measures, as illustrated below:

image.png

image.png

Attempting to implement the above design using AtScale isn't obvious (even in tabular mode).  

 

Procedure

Follow these steps to convert parameterized measures from Power BI to an AtScale cube.   The approach uses AtScale QDS with Calculated Measures.

Step 1.  Create a new dataset in the AtScale cube for Metric selection using SQL

select "Sales Amount" AS Metric
UNION ALL
select "Quantity Sold" AS Metric
UNION ALL
select "Order Count" AS Metric

Screenshot 2023-06-23 at 11.05.50 AM.png

Step 2.  Include the newly created dataset as a fact table and create a degenerate dimension for "Metric".

Screenshot 2023-06-23 at 11.08.03 AM.png

Step 3.  Create a Calculated Measure called "SelectedMetric" using the formula below.

CASE
	WHEN 
		[Metric].[Metric Hierarchy].CurrentMember.MEMBER_NAME = "Sales Amount" 
	THEN 
		[Measures].[Internet Sales Amount Local]
	WHEN 
		[Metric].[Metric Hierarchy].CurrentMember.MEMBER_NAME = "Quantity Sold" 
	THEN 
		[Measures].[Order Quantity Long]
	WHEN 
		[Metric].[Metric Hierarchy].CurrentMember.MEMBER_NAME = "Order Count" 
	THEN 
		[Measures].[Internet Order Count]
	ELSE 
		[Measures].[Internet Sales Amount Local]
END

Screenshot 2023-06-23 at 11.11.19 AM.png

Step 4. Make sure to update the "UNRELATED DIMENSIONS HANDLING" property for the Participating Measures as "Include Repeated Values In Query Results".  In this case, do it for the Measures [Measures].[Internet Sales Amount Local],[Measures].[Order Quantity Long],[Measures].[Internet Order Count]

Screenshot 2023-06-23 at 11.13.39 AM.png

Step 5.  Publish the project.

Step 6.  In Power BI, create a simple report using the above created measure "SelectedMetric" and make sure to include [Metric].[Metric Hierarchy].[Metric] either in the report or in the filter.

Screenshot 2023-06-23 at 11.16.16 AM.png

Result

When you select a metric name, now you will see the values change in the report.  See example below.

Screenshot 2023-06-23 at 11.17.30 AM.png

Screenshot 2023-06-23 at 11.17.22 AM.png

 

Was this article helpful?

0 out of 0 found this helpful