- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Userelationship for multiple dates
Hi
I have this dax that works for filtering lending to drawn on a table.
Drawn Deals =
CALCULATE(
COUNTROWS(Lending), -- Or any other aggregation you'd like
USERELATIONSHIP(Lending[Drawn Date], DateHierarchy[Date]),
DateHierarchy[WeekNum] = SELECTEDVALUE(DateHierarchy[WeekNum])
)
What I need is a combined code that also looks at lead, approved and declined. These stages have a slicer to flip between them, which I need to trigger to the lookup on the relevant date ie if column stage slicer is lead then look at lead date, if slicer is approved look at approved date. The slicer is a week output but it's linked to date table to pull the week though. Lead is the active relationship to the date table while the others are inactive linked to the date table.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @EltonjohnWick ,
You need create stage column as table slicer and then try to create formula like below:
Drawn Deals1 =
VAR SelectedStage =
SELECTEDVALUE ( StageSlicer[Stage] )
RETURN
SWITCH (
TRUE (),
SelectedStage = "Lead",
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Lead Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
),
SelectedStage = "Approved",
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Approved Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
),
SelectedStage = "Declined",
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Declined Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
),
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Drawn Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
)
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much.
Finally works and saves me the visual clutter of having two different date slicer.
Much appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @EltonjohnWick ,
You need create stage column as table slicer and then try to create formula like below:
Drawn Deals1 =
VAR SelectedStage =
SELECTEDVALUE ( StageSlicer[Stage] )
RETURN
SWITCH (
TRUE (),
SelectedStage = "Lead",
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Lead Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
),
SelectedStage = "Approved",
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Approved Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
),
SelectedStage = "Declined",
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Declined Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
),
CALCULATE (
COUNTROWS ( Lending ),
TREATAS ( VALUES ( DateHierarchy[Date] ), Lending[Drawn Date] ),
DateHierarchy[WeekNum] = SELECTEDVALUE ( DateHierarchy[WeekNum] )
)
)
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This seems like a perfect use case for a calculation group. Create a base measure as
Num deals = COUNTROWS( Lending )
and then create a calculation group with items like
Lead Deals = SELECTEDMEASURE()
Drawn Deals =
CALCULATE (
SELECTEDMEASURE(),
-- Or any other aggregation you'd like
USERELATIONSHIP ( Lending[Drawn Date], DateHierarchy[Date] )
)
You don't need to manipulate the relationship for the Lead calculation item because that relationship is already active. And you don't need the SELECTEDVALUE as that filter is already being applied.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @EltonjohnWick,
Can you please try the following approach:
Drawn Deals =
VAR SelectedStage = SELECTEDVALUE(StageSlicer[Stage])
RETURN
SWITCH(
SelectedStage,
"Lead",
CALCULATE(
COUNTROWS(Lending),
DateHierarchy[WeekNum] = SELECTEDVALUE(DateHierarchy[WeekNum])
),
"Approved",
CALCULATE(
COUNTROWS(Lending),
USERELATIONSHIP(Lending[Approved Date], DateHierarchy[Date]),
DateHierarchy[WeekNum] = SELECTEDVALUE(DateHierarchy[WeekNum])
),
"Declined",
CALCULATE(
COUNTROWS(Lending),
USERELATIONSHIP(Lending[Declined Date], DateHierarchy[Date]),
DateHierarchy[WeekNum] = SELECTEDVALUE(DateHierarchy[WeekNum])
),
"Drawn",
CALCULATE(
COUNTROWS(Lending),
USERELATIONSHIP(Lending[Drawn Date], DateHierarchy[Date]),
DateHierarchy[WeekNum] = SELECTEDVALUE(DateHierarchy[WeekNum])
),
BLANK()
)
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
Thanks for sending on, however this didn't work. I can see the stage options available for the relevant week but the table is blank when I add the measure

Helpful resources
Subject | Author | Posted | |
---|---|---|---|
11-22-2024 08:57 AM | |||
11-15-2024 08:35 AM | |||
12-18-2024 10:15 AM | |||
05-06-2024 11:49 AM | |||
12-19-2024 01:23 AM |
User | Count |
---|---|
14 | |
13 | |
11 | |
10 | |
8 |
User | Count |
---|---|
19 | |
16 | |
14 | |
13 | |
11 |