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
bwang2
Helper I
Helper I

need some help with this DAX

I have two CM

"DSKfromlastcyle =
VAR _PreviousCycle = SELECTEDVALUE(CC[CycleNum])-1
VAR _DateShiftKetAfter = CALCULATE(MAX(DimCrewSchedule[DateShiftKey]),CC[CycleNum]= _PreviousCycle)

RETURN _DateShiftKetAfter"
This CM gives me the desired outcome. But the one CM below is not.
"
SortingNum =
CALCULATE(MAX(DimCrewSchedule[SortingNum]),FILTER(DimCrewSchedule,DimCrewSchedule[DateShiftKey] = [DSKfromlastcyle]))"

An example outcome of CM1 is "20240101DS" and the corresponding CM2 outcome is "1". When I run CM2, it's giving me blank, but if I mannualy type "20240101DS" insted of "[DSKfromlastcyle]", it will give me "1" as the outcome. 

Below is a portion of my DIMCrewSchedule Table
DateShiftKeySortingNum
20240101DS1
20240101NS2
20240102DS3
20240102NS4
20240103DS5
20240103NS6
20240104DS7
20240104NS8
20240105DS9
20240105NS10
1 ACCEPTED SOLUTION
hackcrr
Continued Contributor
Continued Contributor

Hi, @bwang2 

Thank you very much for your reply. You should put this metric and DateShiftKey column in table visual. See if you get the expected results. The metric needs to rely on an external context such as the DateShiftKey column to work.

 

Best Regards,

hackcrr

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

View solution in original post

5 REPLIES 5
hackcrr
Continued Contributor
Continued Contributor

Hi, @bwang2 

Perhaps you could try the following dax expression:

SortingNum1 = 
VAR DSKValue = [DSKfromlastcyle]  
RETURN  
    CALCULATE(  
        MAX(DimCrewSchedule[SortingNum]),  
        FILTER(ALLSELECTED(DimCrewSchedule),
        DimCrewSchedule[DateShiftKey] = DSKValue
        )
    )

The results are as follows:

hackcrr_0-1715419747388.png

 

 

Best Regards,

hackcrr

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

@hackcrr 

bwang2_0-1715597549792.png

Thanks for helping, I tried the DAX you provided, but it still gives me blank

hackcrr
Continued Contributor
Continued Contributor

Hi, @bwang2 

Thank you very much for your reply. You should put this metric and DateShiftKey column in table visual. See if you get the expected results. The metric needs to rely on an external context such as the DateShiftKey column to work.

 

Best Regards,

hackcrr

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

bhanu_gautam
Super User
Super User

@bwang2 , Make some changes in second CM 

 

SortingNum =
VAR SelectedDateShiftKey = [DSKfromlastcyle]
RETURN
CALCULATE(
MAX(DimCrewSchedule[SortingNum]),
DimCrewSchedule[DateShiftKey] = SelectedDateShiftKey
)





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@bhanu_gautam 
Thanks for helping, I tried the DAX you provided, but it still gives me blank

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors