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
imyconco
Frequent Visitor

Use Selectedvalue (from 2 different slicers) to creating a cumulative metric with DAX

Hi, I hope you can help me as I have been trying to do this for days and somehow it doesnt work. 
I have a data table like the example below (this is just an example),  a Calendar table and a Parameter (Reference Plan).
I would like to use 2 slicers, one with the Calendar[Month Name] and the other with the Paramenter[RefNo], so wehn I filter for example Month= February and Reference Plan = February I will get the cumulative sum for those records that are January & February (highlighted in yeloow below).

 

Data table:

imyconco_0-1702982918071.png 

Paramenter:

imyconco_2-1702983267096.png


Calendar:

imyconco_3-1702983666843.png

 

I have created the folloing metric attemps but none work:

 

ACTUALS test = VAR selectedmonth = SELECTEDVALUE('Calendar'[Month])
VAR RefPlan =  SELECTEDVALUE(REFERENCE_PLAN[RefNo])
Return
CALCULATE([Commitment ACTUALS],
    FILTER( ALLSELECTED(financialmonthlystatus), financialmonthlystatus[Month (Period)] <= selectedmonth && financialmonthlystatus[creationperiod] <= RefPlan)
    )

 

This metric only returns when period and creation period are February = 4

Please note [Commitmet Actuals] is a metric sumarizing all amounts and filetring by Group Type = "COMMITMENT" and feature = "ACTUALS".
 
Please let me know if you need more information,
Many thanks!
Imy
11 REPLIES 11
imyconco
Frequent Visitor

I need to be able to use a selector for period month (using the calendar table) and a selector from a parameter (RefNo) which is either Feb or Sep. This wold be the SelectedValues.

With this I need to be able to create a metric to summarize the amounts where the Month (period) are <= selected Month (Period) and Month (creationdate)<=selected RefNo.

I tried maany ways but it doesnt work: 

ACTUALS_Cut-OffYTD new = VAR selectedmonth = SELECTEDVALUE('Calendar'[Month])
VAR RefPlan =  SELECTEDVALUE(REFERENCE_PLAN[RefNo])
Return
calculate([Commitment ACTUALS], financialmonthlystatus[Month (Period)] <= selectedmonth && financialmonthlystatus[Month (Creation)]<= RefPlan)
Indeed is a cummulative metric from a metric.
What am I doing wrong?
 
lbendlin
Super User
Super User

You want a cumulative measure ?

lbendlin_0-1704224816332.png

 

 

Hi, what I need is a cummulative metric compared to 2 dates. These 2 dates come from a selectedvalue on two slicers. I really dont seem to be able to calculate this.

Please indicate the expected outcome based on the sample data you provided.

Hi, here is a simple example, i would like to have a cummulative or runnning sum of the amount (commitment Actuals), where Month (period) is <= to the selected value from the slicer (Month) (in this screenshot is 2); and the Month (creationperios) is <= to the selected value in Reference Plan (in this case also 2). My result on this example should be 347:

imyconco_0-1705564957500.png

 

Change your visual to a matrix and put the "Month creation date"  as a column

 

lbendlin_0-1705609644670.png

 

I need to be able to use a selector for period month (using the calendar table) and a selector from a parameter (RefNo) which is either Feb or Sep. This wold be the SelectedValues.

With this I need to be able to create a metric to summarize the amounts where the Month (period) are <= selected Month (Period) and Month (creationdate)<=selected RefNo.

I tried maany ways but it doesnt work: 

ACTUALS_Cut-OffYTD new = VAR selectedmonth = SELECTEDVALUE('Calendar'[Month])
VAR RefPlan =  SELECTEDVALUE(REFERENCE_PLAN[RefNo])
Return
calculate([Commitment ACTUALS]financialmonthlystatus[Month (Period)] <= selectedmonth && financialmonthlystatus[Month (Creation)]<= RefPlan)
Indeed is a cummulative metric from a metric.
What am I doing wrong?
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

You tried to link to your report - that is not recommended.  Please prepare sanitized sample data and share that.

CodeYear (period)Month (period)periodYear (creationdate)Month (creationdate)creationdate amount groupTypeFeature
D/1242023201/02/20232023301/03/2023                 301BCOMMITMENTACTUALS
D/1262023401/04/20232023501/05/2023402DCOMMITMENTACTUALS
D/1282023601/06/20232023701/07/20232ACOMMITMENTACTUALS
D/1242023101/01/20232023301/03/2023                      5CCOMMITMENTACTUALS
D/12620231001/10/202320231101/11/202322ECOMMITMENTACTUALS
D/12820231201/12/20232024101/01/202449BCOMMITMENTACTUALS
D/1242023201/02/20232023301/03/2023                 300DCOMMITMENTACTUALS
D/1262023401/04/20232023501/05/2023100ACOMMITMENTACTUALS
D/1282023601/06/20232023701/07/202369CCOMMITMENTACTUALS
D/1242023201/02/20232023201/02/2023                   32ECOMMITMENTACTUALS
D/12620231001/10/202320231101/11/2023300BCOMMITMENTACTUALS
D/12820231201/12/20232024101/01/202468DCOMMITMENTACTUALS
D/1302022201/02/20222022301/03/202287ACOMMITMENTACTUALS
D/1232022401/04/20222022501/05/20223CCOMMITMENTACTUALS
D/1252022601/06/20222022701/07/20229ECOMMITMENTACTUALS
D/1272022801/08/20222022901/09/202226BCOMMITMENTACTUALS
D/12320221001/10/202220221101/11/202275DCOMMITMENTACTUALS
D/12520221201/12/20222023101/01/2023200ACOMMITMENTACTUALS
D/1252022201/02/20222022301/03/202250CCOMMITMENTACTUALS
D/12420221201/12/20222022101/01/2023                   48ECOMMITMENTACTUALS
D/1262022601/06/20222022701/07/2022102BCOMMITMENTACTUALS
D/1282022801/08/202220221001/10/2022242DCOMMITMENTACTUALS
D/12420221001/10/202220221101/11/2022                 382ACOMMITMENTACTUALS
D/12620221201/12/20222023101/01/2023522CCOMMITMENTACTUALS
D/1282021901/09/202120211001/10/2021662ECOMMITMENTACTUALS
D/12420211101/11/202120211201/12/2021                 802BCOMMITMENTACTUALS
D/1242023201/02/20232023201/02/2023                 300DCOMMITMENTACTUALS
D/1242023101/01/20232023201/02/2023                   15CCOMMITMENTACTUALS
D/1242023101/01/20232023301/03/2023                   10CCOMMITMENTACTUALS
D/1242023801/08/20232023901/09/202332ECOMMITMENTACTUALS

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.

Top Solution Authors