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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
bcobrien1977
Helper IV
Helper IV

Employee Count with Different Versions and Dates

Hi,

I am trying to normalize some outside data and there are basically duplicate values for most of 2024 and some of 2023 so I need to be able to use the Agg Type of V2 if present and greater than 1 and else use v1. 

 

This is a sample of the data but it doesn't fit perfectly.  I feel like I just can't get the dax right.  Does anyone have any ideas?    The Date table is connected to the report date of the data table  Thanks

Report DateAggTypeResolved Count
23-FebV15012
23-MarV15074
23-AprV14748
23-MayV14968
23-JunV15014
23-JulV14641
23-AugV15293
23-SepV14752
23-SepV21
23-OctV14451
23-OctV217
23-NovV14113
23-NovV23790
23-DecV14966
23-DecV24764
24-JanV15586
24-JanV25488
24-FebV14766
24-FebV24685
24-MarV14350
24-MarV24350
24-AprV26748
1 ACCEPTED SOLUTION
v-huijiey-msft
Community Support
Community Support

Hi @bcobrien1977 ,

 

Thanks for the reply from @smpa01 .

 

In my understanding, your requirement is to return the Resolved Count of V2 if there is more than one value for the same year and month, otherwise return the Resolved Count of V1. am I understanding correctly?

 

Although your date column only has year and month, powerbi may recognize different days, for example, February automatically recognizes the 23rd and 24th.

vhuijieymsft_0-1715660083286.png

 

Therefore, you need to create a new Year Month column:

Year Month = FORMAT('Table'[Report Date],"yyyy-mm")

 

Create a sort column so that the Year Month column is sorted by this column:

Year Month Sort = YEAR('Table'[Report Date])*12+MONTH('Table'[Report Date])

vhuijieymsft_1-1715660083294.png

 

Create a Measure that counts the number of each Year Month column:

Count = 
CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Year Month]))

 

Creates a Measure and returns the Resolved Count of V2 for the same date if count>1, otherwise returns the Resolved Count of V1:

Measure 2 = IF(
    [Count] > 1,
    CALCULATE( MAX ( 'Table'[Resolved Count] ), ALLEXCEPT('Table','Table'[Year Month]), 'Table'[AggType] = "V2"  ),
    CALCULATE ( MAX ( 'Table'[Resolved Count] ), ALLEXCEPT('Table','Table'[Year Month]) , 'Table'[AggType] = "V1")
)

 

The final page result is shown below:

vhuijieymsft_2-1715660092357.png

 

The pbix file is attached.

 

If you have other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

2 REPLIES 2
v-huijiey-msft
Community Support
Community Support

Hi @bcobrien1977 ,

 

Thanks for the reply from @smpa01 .

 

In my understanding, your requirement is to return the Resolved Count of V2 if there is more than one value for the same year and month, otherwise return the Resolved Count of V1. am I understanding correctly?

 

Although your date column only has year and month, powerbi may recognize different days, for example, February automatically recognizes the 23rd and 24th.

vhuijieymsft_0-1715660083286.png

 

Therefore, you need to create a new Year Month column:

Year Month = FORMAT('Table'[Report Date],"yyyy-mm")

 

Create a sort column so that the Year Month column is sorted by this column:

Year Month Sort = YEAR('Table'[Report Date])*12+MONTH('Table'[Report Date])

vhuijieymsft_1-1715660083294.png

 

Create a Measure that counts the number of each Year Month column:

Count = 
CALCULATE(COUNTROWS('Table'),ALLEXCEPT('Table','Table'[Year Month]))

 

Creates a Measure and returns the Resolved Count of V2 for the same date if count>1, otherwise returns the Resolved Count of V1:

Measure 2 = IF(
    [Count] > 1,
    CALCULATE( MAX ( 'Table'[Resolved Count] ), ALLEXCEPT('Table','Table'[Year Month]), 'Table'[AggType] = "V2"  ),
    CALCULATE ( MAX ( 'Table'[Resolved Count] ), ALLEXCEPT('Table','Table'[Year Month]) , 'Table'[AggType] = "V1")
)

 

The final page result is shown below:

vhuijieymsft_2-1715660092357.png

 

The pbix file is attached.

 

If you have other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

smpa01
Super User
Super User

@bcobrien1977  can you try this

Measure =
VAR baseTbl =
    SUMMARIZE (
        ALL ( _tbl ),
        _tbl[Report Date],
        _tbl[AggType],
        _tbl[Resolved Count]
    )
VAR f1 =
    FILTER ( baseTbl, [Report Date] = MAX ( _tbl[Report Date] ) )
VAR _count =
    COUNTROWS ( f1 )
VAR factV2 =
    CALCULATE ( MAX ( _tbl[Resolved Count] ), FILTER ( f1, _tbl[AggType] = "V2" ) )
VAR factV1 =
    CALCULATE ( MAX ( _tbl[Resolved Count] ), FILTER ( f1, _tbl[AggType] = "V1" ) )
VAR ternary =
    IF ( _count > 1 && factV2 > 1, factV2, factV1 )
RETURN
    ternary
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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