Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

DAX Calculation Group by, with date slicer condition

Gurus,

Have a requirement.  Here's the scenario.  Need to comput the PCL column using the formula below: (base table: Brrw):- 

-------------------------------------------------------------------------------------

Report Date (Slicer)   (This is a dropdown, chosen by the user)

dd-mon-yy                 <--- Field :  Brrw[ReportDate]

 Industry                      LnAmt      CrdAmt       PCL 

AGRICULTURE             10000       20000        ?

      livestock                    5000      10000        ?                            <-- Sub Industry 

      Fruits & Veg             5000      10000        ?

OIL & GAS                   20000       50000        ?

      Exploration             

      Pipelines 

-----------------------------------------------------------

1) Compute SUM(LnAmt), SUM(CrdAmt)  where Brrw[ReportDate] > Report Date(Slicer) - 12     Group by Industry 

2) PCL = SUM(LnAmt) / AVG(SUM(CrdAmt)) Group by Industry 

Need to have the PCL values for Industry and Sub Industry (they are both hierarchies).  The condition in Step 1,  am unable to get my head around(Slicer value, can it be assigned to a variable?). Any idea welcome.

Thanks in advance

 

 

 

 

 

 

   

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , You can have formula like

measure =
var _max =maxx(allselected(Date), Date[Date])
var _min = date(year(_max), month(_max)-12,day(_max))
return
calculate([measure], filter(Table, Table[Join Date]>=_min))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , You can have formula like

measure =
var _max =maxx(allselected(Date), Date[Date])
var _min = date(year(_max), month(_max)-12,day(_max))
return
calculate([measure], filter(Table, Table[Join Date]>=_min))

Anonymous
Not applicable

@amitchandak  Excellent!!  Thank you for your time.  Works perfectly.  (Powerbi community is just amazing)

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.