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
Anonymous
Not applicable

SelectedValue DAX in ameasure to reference value from other column

Hi community,

 

I've 2 KPI cards; one shows the unique user count for the current month based on the filter selected (the slicer right now is a month number), the second KPI shows last months unique user count, this is also based on the filter selected.

 

Measure I've created is- 

LM_User_Count = calculate(countdistinct(User_Id), Table[MonthNo] = selectedvalue(Table[MonthNo]) -1)

 

This measure does give me the correct number but I am limited to putting a numerical value in my slicer, I want that to be a short form of month, which is there in the table in column MonthName.

 

Highly appreciate any help! Thank you

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

If you want to get the short form of month and put it into slicer, you can add a calculated column with short form of month in your initial table, then put it into slicer,vxiaotang_1-1637203296759.png

MonthName = FORMAT('Table'[date],"mmm")

 

 

LM_User_Count = calculate(countdistinct(User_Id), Table[MonthNo] = selectedvalue(Table[MonthNo]) -1)

then try your measure again.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

If you want to get the short form of month and put it into slicer, you can add a calculated column with short form of month in your initial table, then put it into slicer,vxiaotang_1-1637203296759.png

MonthName = FORMAT('Table'[date],"mmm")

 

 

LM_User_Count = calculate(countdistinct(User_Id), Table[MonthNo] = selectedvalue(Table[MonthNo]) -1)

then try your measure again.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , if you have date use date table and time intelligence or create date using month year and use it.

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

Power BI — Month on Month with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-mtd-questions-time-intelligence-3-5-64b0b4a4090e
https://www.youtube.com/watch?v=6LUBbvcxtKA

Anonymous
Not applicable

Hi Amit, thanks for the prompt reply, I tried using this it doesnt work. I created a date table, but if I try creating a relation between the date table and my base table, the date column goes for toss and if I dont connect and still use the same measure as suggested above, the -1 logic doesnt work

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.