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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
rautaniket0077
Resolver I
Resolver I

Aggregation based on group by/ summarization and filter.

 Hi, i have attached the sample data now there are couple of things that i want to achieve using power bi-

 

1) first thing is i need to filter the table  based on the month-year selected from the slicer if aug-2024 is selected then i want to show me the data from aug-2023 to july 2024.

 

2) on the top of this filtered data, i need to calculate sum of these internal, external, insurance and warranty based on grouping by vin

 

3)after this based on summesion, i need to calculate the count of external when internal, warranty and insurance is 0

 

 you can use the archived date from table for doing the calculation

@mark_endicott ,  @johnt75 , @DataNinja777@amitchandak@lbendlin   and everyone else please help here. 

VINDate ArchivedMileageAmountExternalInternalInsuranceWarrantySumYearBrands    
LACZZZ70ZXC0036519/1/2023211024536.6300031999A    
WV2ZZZ2KZEX1186379/22/20231364984973.6400042014A    
WV2ZZZ7HZGH1101879/23/20232966230884.7312200142018B    
WV2ZZZ7HZGH1101879/24/20232966226706.64710082018B    
WV2ZZZ7HZ9H0203529/25/2023920192458.0117000172008B    
WV2ZZZ7HZLH0850289/26/20231330416861.44004042021B    
WV1ZZZ2HZJH3001499/27/20238442699919.88010452019C    
WV2ZZZSK8NX0664909/28/20231663345.66030032023C    
WV2ZZZ7HZKH1559319/29/202315755273030032020C    
WV2ZZZ7HZNH0504639/30/2023270808535.68010452022D    
WV2ZZZ2KZEX09008210/1/2023118782889.48500052014D    
WV2ZZZ7HZCH09488510/2/20231852621625100012012D    
Want calculation like below considering the date selected by user from slicer is aug-2024 , hence taking the data from aug-2023 to jul-2024              
VINExternalinternalinsurancewarrantysum         
LACZZZ70ZXC00365130003         
WV2ZZZ2KZEX11863740004         
WV2ZZZ7HZGH1101871930022         
WV2ZZZ7HZ9H0203521700017         
WV2ZZZ7HZLH08502800404         
WV1ZZZ2HZJH30014901045         
WV2ZZZSK8NX06649003003         
WV2ZZZ7HZKH15593103003         
WV2ZZZ7HZNH05046301045         
WV2ZZZ2KZEX09008250005         
WV2ZZZ7HZCH09488510001         
               
Expected output              
External = 5              

 

8 REPLIES 8
rautaniket0077
Resolver I
Resolver I

Hi@v-jiewu-msft, @tharunkumarRTK@DataNinja777,@mark_endicott , @johnt75 , @DataNinja777, @amitchandak, @lbendlin,

The measure which @tharunkumarRTK given is working fine with the sample data but its giving me blank values in my current report instead i have used the below measures to calculate internal, external, warranty and insurance.

internal new =

var _date = MAX(Calender[Date])

var _result =
CALCULATE(
    SUM(Fact_Car_Service_Summary[internal]),
    DATESINPERIOD(
        Calender[Date],
        EOMONTH(_date,-1),
        -12,
        MONTH)
)

return _result

same way i have calculated for the rest.

rautaniket0077_0-1737347994501.png

now the thing is i just need the count whenever there is a sum of internal >0 and rest i.e. insurance, warranty and external is 0. I have uesed the below measure in which i have used IF but i know that this is not giving  me the count instead it is compairing and giving 1 and 0.

Internal cnt new corrected =

var _date = MAX(Calender[Date])

var _result =
CALCULATE(
    DISTINCTCOUNT(Fact_Car_Service_Summary[vin]),
    DATESINPERIOD(
        Calender[Date],
        EOMONTH(_date,-1),
        -12,
        MONTH
    )
)

RETURN
IF(
    [external new]+
    [warranty new]+
    [insurance new]=0,
    _result,
    0
)
Note :- i need to show the count in separate KPI card and not in table visual.

Thank you.




 






Hi,

Try creating a new page and re-adding the table data, metrics, and filters on that page to see if there are still issues. The expression provided above gives the correct results.

 

Best Regards,

Wisdom Wu

Hello Aniket,

Based on the data and discussions in the posts, I have created a PBIX file that includes two solutions: one with a relationship and one without. Please take a look at the attached PBIX for further details.

PawarNovil_0-1737713601629.png

attachment: https://drive.google.com/file/d/1gFeD3iqrO5eLYCfCuzsxfFH9ibRS2tkg/view?usp=sharing

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

Regards,

Novil

If I answer your question, please mark my post as a solution.

v-jiewu-msft
Community Support
Community Support

Hi ,

If you have a problem with the data type, try changing the date type to date.

For the condition that the year to be equals to year of selected date, creating the new measure to filter the values.

Measure = 
var _year = SELECTEDVALUE('Date'[MonthYear])
RETURN
IF(YEAR(_year) = SELECTEDVALUE(Data[Year]), 1, 0)

Drag the measure to the table visual Filters pane and set show item is 1.

vjiewumsft_0-1737102313363.png

 

Best Regards,

Wisdom Wu

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

tharunkumarRTK
Super User
Super User

@rautaniket0077 

Screenshot 2025-01-12 at 3.10.56 PM.png

Please find the PBIX attached 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

 

Hi @tharunkumarRTK
Thank you for the reply i guess this will work but the thing is my data is having some data type issue and hence my sum is giving me blank, is it possible to implement the same by using the archive date and not by using date from calender table.
Apart from this i have one more extra filter condition to add which is year which needed to be equals to year of selected date from the slicer (which is archived date).

 

DataNinja777
Super User
Super User

Hi @rautaniket0077 ,

 

Here’s the final version that works and dynamically counts the rows for the last 12 months:

External_Count_Only =
CALCULATE(
    COUNTROWS(
        FILTER(
            'Table',
            'Table'[External] > 0 &&
            'Table'[Internal] = 0 &&
            'Table'[Warranty] = 0 &&
            'Table'[Insurance] = 0
        )
    ),
    'Calendar'[Date] >= MAX('Calendar'[Date]) - 365
)

 

DataNinja777_0-1736673132858.png

 

I have attached an example pbix file for your reference.

 

Best regards,

 

Hi @DataNinja777 ,
Thank you for the reply we want to exclude current month-year and -365 from your measure include it, for more details please check my post and my reply to @tharunkumarRTK .

Thank you. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.