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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Maru
Helper I
Helper I

Get the latest value (also group by slicer filter)

There are 'open order' transactions but the data sometimes not fully available daily.

 

So, to get a closure for a specific month, it has to be calculated from the last date (per each available group)


The group is also part of slicers. This should be easy but still I am only get it half way.  


Here is an example data where country is a slicer. (let say another date slicer is in December so it should show November data)

 

dateproductopen ordercountry
10/25/2023apple3china
10/25/2023apple32india
11/13/2023apple1china
11/13/2023apple4india
11/15/2023apple7china
11/15/2023apple11india
11/22/2023apple6china
11/22/2023apple12india
11/23/2023apple5china
11/24/2023apple9india
12/11/2023apple2china
12/18/2023apple12india

 

 


Current DAXs I have:

month closure = CALCULATE( sumx('Table', 'Table'[open order]),
                       filter('Table', 'Table'[date] =  CALCULATE(     max('Table'[date]      )  ,
                             filter ( 'Table' , month('Table'[date]) = month( max('Table'[date]))-1)
                                                                    )
                            )
               )
month closure 2 =
SUMX (
    SUMMARIZE (
        'Table',
        'Table'[country],
        "@Value", SUMX ( TOPN ( 1, 'Table', 'Table'[Date] )  , 'Table'[open order] )
    ),
    [@Value]
)

 

Am I just lose in a DAX context ?
10 REPLIES 10
LufengYuan
Frequent Visitor

Var __Result = CALCULATE( MAX(Table14[open order]) , 'Calendar'[Date] =  __LastDate)

Try to change from Max(Table14[open order]) to Sum(Table14[open order]), does it works for your total to be 14?

Unfortuntely not.

Maru_0-1705374016891.png

 

Fowmy
Super User
Super User

@Maru 

Suppose your have a calendar table connected, use this meaure:

Lastest Value = 
Var __DatePre = EOMONTH( MAX('Calendar'[Date]), -1)
Var __LastDate = 
    CALCULATE(
        MAX(Table14[date]),
    'Calendar'[Date]< __DatePre
    )
Var __Result = CALCULATE( MAX(Table14[open order]) , 'Calendar'[Date] =  __LastDate)
RETURN
    __Result

Fowmy_0-1705320427603.png

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Total has to be 14

@Maru 

Try this measure:

Lastest Value = 
Var __DatePre = EOMONTH( MAX('Calendar'[Date]), -1)
Var __Result = 
    SUMX(
        VALUES( Table14[country]),
        Var __LastDate = CALCULATE( MAX(Table14[date]),'Calendar'[Date]< __DatePre)
        Var __OpenOder = CALCULATE( MAX(Table14[open order]) , 'Calendar'[Date] =  __LastDate)
        RETURN
        __OpenOder
    )
RETURN
    __Result 

 

Fowmy_0-1705376660384.png

 




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you for the update but I believe it requires either 'group by' or 'allexcept' to make it work with slicer. @Fowmy 

Maru_0-1705387789921.png

Maru_2-1705388186648.png

 

 

 

@Maru 

Sure, you may modify my solution to suit your needs. If what I shared was helpful, please go ahead and accept it as a solution. 


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

That is what I am after and yet be able to do it so post this thread ( in case it mat not possible )

Have to give credit to Fowmy. I adjusted the formula as blow. seems work. Hope it is helpful for you.

LufengYuan_0-1705710454014.png

 

Would it work if you select 'Jan' ?

Maru_0-1706500640021.pngMaru_1-1706500671877.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors