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
vickyprudhvi
Helper IV
Helper IV

Dax Measure

DateDimensionIDJobCloseDatePolicyNumberTermNumberBranchIDJobMostRecentModel
17/1/2016 0:00A11Submission1
27/2/2016 0:00A12Policy Change1
27/2/2016 0:00B12Policy Change1
37/3/2016 0:00A13Cancellation0
37/3/2016 0:00B13Cancellation0
37/3/2016 1:00A14Reinstatement1
37/3/2016 1:00B14Reinstatement1
47/5/2016 0:00A15Cancellation1

Hi,

Above is the sample table I am working on. I looking to Calculate PolicyCount. It should count policies that has Previous Job type as  Reinstatement

Example

JobcloseDate =7/5/2016 0:00 then it should show 1 policies (Which is Policy A because on 7/3/2016 it is reinstated)

I am not able to write exact measure to reflex this on Power BI Desktop.

Kindly help

 

 

4 REPLIES 4
v-qiuyu-msft
Community Support
Community Support

Hi @vickyprudhvi,

 

You can also create a measure and place the measure in a table visual, see:

 

PolicyCount = 
VAR TempCount =
    CALCULATE (
        COUNTROWS ( Table1 ),
        FILTER (
            ALL( Table1 ),
            Table1[JobCloseDate] < MAX ( Table1[JobCloseDate] )
                && Table1[Job] = "Reinstatement"
        ),
        VALUES ( Table1[PolicyNumber] )
    )
RETURN
    ( IF ( TempCount = BLANK (), 0, TempCount ) )

 

 

x1.PNG

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-qiuyu-msft

thank you for ur reply

I am trying to create a measure in tabular model

 

Hi @vickyprudhvi,

 

Do you mean you want to write the measure on SSAS side instead of Power BI desktop? In my opinion, you can also achieve your requirement by create a measure in Power BI Dekstop. If you want to create a measure in tabular model, you can post the issue in SSAS forum: https://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?forum=sqlanalysisservices.

 

Best Regards,
Qiuyun Yu

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-qiuyu-msft
Community Support
Community Support

Hi @vickyprudhvi,

 

In your scenario,  I would suggest you create a calculated column which returns Previous Job type for each row, then decide whether it's Reinstatement. See:

 

PreviousJob = LOOKUPVALUE(Sheet1[Job],Sheet1[BranchID],Sheet1[BranchID]-1,Sheet1[PolicyNumber],"A")

 

CountPolices = IF(Sheet1[PreviousJob]="Reinstatement",1,0)

 

z1.PNGz2.PNG

 

If you have any question, please feel free to ask.

 

Best Regards,
Qiuyun Yu

 

Community Support Team _ Qiuyun Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.