Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello,
I have a parameter that allows me to toggle between two different measures in my report. I created this parameter using the new parameter functionality in the modeling tab of Power BI. Here is the parameter information:
Parameter Table: PARM Gross/Net Script Ct
Fields:
The two rows in the parameter table are:
Paramter table:
Script Count (Excluding Cancels) = CALCULATE(SUM('LDRSHP_RPT_FAC'[GRSS_SCRP_CNT]), ISBLANK('LDRSHP_RPT_FAC'[SCRP_CNL_DT]))
Gross Script Count = SUM(LDRSHP_RPT_FAC[GRSS_SCRP_CNT])
My challenge is that I have a measure, LY Gross Script Ct, which doesn't update based on the selection made using the parameter in a slicer. Here is the DAX for that measure:
LY Gross Script Ct =
VAR max_date = CALCULATE(LASTDATE(DT_DIM[DAY_DT]), ALL(DT_DIM))
VAR max_year = CALCULATE(VALUES(DT_DIM[FCL_YR_ID]), ALL(DT_DIM), DT_DIM[DAY_DT] = max_date)
VAR target_year = FORMAT(SELECTEDVALUE(DT_DIM[FCL_YR_ID], max_year) - 1, "General Number")
VAR today_fiscal = CALCULATE(VALUES(DT_DIM[FCL_DAY_OF_YR_ID]), ALL(DT_DIM), DT_DIM[DAY_DT] = max_date)
VAR result = CALCULATE([Gross Script Count], DT_DIM[FCL_YR_ID] = target_year, DT_DIM[FCL_DAY_OF_YR_ID] <= today_fiscal,
DT_DIM[FCL_DAY_OF_YR_ID] in DISTINCT(DT_DIM[FCL_DAY_OF_YR_ID]))
RETURN result
I want this measure to use either the 'Gross Script Count' or the 'Script Count (Excluding Cancels)' depending on the selection in the slicer, but it seems to be using the 'Gross Script Count' exclusively, regardless of the slicer selection.
Any guidance on how to make the LY Gross Script Ct measure respect the slicer selection would be greatly appreciated. Thank you in advance for your help.
Hi @nunezjo ,
For this you need to change the logic on the measure using an if statement it would look something similar to this:
LY Gross Script Ct =
VAR max_date = CALCULATE(LASTDATE(DT_DIM[DAY_DT]), ALL(DT_DIM))
VAR max_year = CALCULATE(VALUES(DT_DIM[FCL_YR_ID]), ALL(DT_DIM), DT_DIM[DAY_DT] = max_date)
VAR target_year = FORMAT(SELECTEDVALUE(DT_DIM[FCL_YR_ID], max_year) - 1, "General Number")
VAR today_fiscal = CALCULATE(VALUES(DT_DIM[FCL_DAY_OF_YR_ID]), ALL(DT_DIM), DT_DIM[DAY_DT] = max_date)
var selectedmeasure = IF(SELECTEDVALUE(PARM Gross/Net Script Ct[PARM Gross/Net Script Ct Order] = 1, [Gross Script Count], [Script Count (Excluding Cancels)]
VAR result = CALCULATE(selectedmeasure , DT_DIM[FCL_YR_ID] = target_year, DT_DIM[FCL_DAY_OF_YR_ID] <= today_fiscal,
DT_DIM[FCL_DAY_OF_YR_ID] in DISTINCT(DT_DIM[FCL_DAY_OF_YR_ID]))
RETURN result
Regards
Miguel Félix
Proud to be a Super User!
Check out my blog: Power BI em PortuguêsI got it to work using the following, although it's not doing what I want it to do. It's not giving me data from Last Fiscal Year. It's giving me data from all years.
LY Gross Script Ct =
VAR max_date = CALCULATE(LASTDATE(DT_DIM[DAY_DT]), ALL(DT_DIM))
VAR max_year = CALCULATE(VALUES(DT_DIM[FCL_YR_ID]), ALL(DT_DIM), DT_DIM[DAY_DT] = max_date)
VAR target_year = FORMAT(SELECTEDVALUE(DT_DIM[FCL_YR_ID], max_year) - 1, "General Number")
VAR today_fiscal = CALCULATE(VALUES(DT_DIM[FCL_DAY_OF_YR_ID]), ALL(DT_DIM), DT_DIM[DAY_DT] = max_date)
VAR selectedmeasure =
IF(
SELECTEDVALUE('PARM Script Ct'[PARM Gross/Net Script Ct Order]) = 1,
[Gross Script Count],
[Script Count (Excluding Cancels)]
)
VAR result = CALCULATE(selectedmeasure , DT_DIM[FCL_YR_ID] = target_year, DT_DIM[FCL_DAY_OF_YR_ID] <= today_fiscal,
DT_DIM[FCL_DAY_OF_YR_ID] in DISTINCT(DT_DIM[FCL_DAY_OF_YR_ID]))
RETURN result
When trying to use the above I get an error. It says Paramter is not the correct type. Not sure what I'm doing wrong .
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
85 | |
66 | |
51 | |
45 |
User | Count |
---|---|
217 | |
89 | |
82 | |
66 | |
57 |