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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
adelaidiana
Frequent Visitor

Count if multiple conditions in different tables

Hi all, I am totally new on this jurney and I need to do a report and calculate how many rows have data based on other 3 conditions based on diferent tables. I need to create the report in Table 3. Ex: If Table 1 (Asset Eq=Cars and Model number=x), filter Table 2 Asset Equipment column for Cars and count under Model Number column how many entries we have. This number has to appear in Table 3 under Model Number /Cars.  Table 3 is a duplication of Table 1, just when we have x, we need the numbers of cells with data from Table 2. I have already completed Table 3 with the results we should obtain from the report.

 

Thank you so much in advance for all your help.

 

Asset EquipmentModel numberManufacturerStart-up date
Carsxxx
Bicyclesx x
Scouters  x

 

Asset EquipmentEquipmentModel numberManufacturerStart-up date
Cars20015234Model 1a01/01/1980
Bicycles20015235Model 2b01/01/1980
Cars20015236Model 3x01/01/1980
Scouters20015247Model 4x 
Bicycles20015271Model 5 30/03/2007
Scouters20015398Model 6 01/01/1992
Cars20015403Model 7b 
Bicycles20015702Model 8 01/01/1987
Scouters20015703   
Cars20015746Model 10x01/01/1980
Scouters20015772Model 11 02/01/1980
Bicycles20015773Model 12x 
Cars20015774Model 13b04/01/1980
Scouters20015775Model 14 05/01/1980
Scouters20015779  06/01/1980
Bicycles20015840Model 16 07/01/1980
Scouters20015877Model 17x08/01/1980
Cars20015879Model 18  
Cars20015885Model 19b10/01/1980
Scouters20015886Model 20 11/01/1980
Bicycles20015946Model 21 12/01/1980
Cars20015947  13/01/1980
Cars20015948Model 23  
Bicycles20015949Model 24b15/01/1980
Cars20015964Model 25 16/01/1980

 

Asset EquipmentModel numberManufacturerStart-up date
Cars967
Bicycles7 6
Scouters  6
1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1697693190721.png

 

 

New Table DAX formula =
VAR _t01 =
    SELECTCOLUMNS (
        Table1,
        "@assetequipment", Table1[Asset Equipment],
        "@modelnumber", IF ( Table1[Model number] <> BLANK (), 1 ),
        "@manufacturer", IF ( Table1[Manufacturer] <> BLANK (), 1 ),
        "@startupdate", IF ( Table1[Start-up date] <> BLANK (), 1 )
    )
VAR _t02 =
    SELECTCOLUMNS (
        Table2,
        "@assetequipment", Table2[Asset Equipment],
        "@modelnumber", IF ( Table2[Model number] <> BLANK (), 1 ),
        "@manufacturer", IF ( Table2[Manufacturer] <> BLANK (), 1 ),
        "@startupdate", IF ( Table2[Start-up date] <> BLANK (), 1 )
    )
VAR _result =
    ADDCOLUMNS (
        _t01,
        "ModelNumber",
            IF (
                [@modelnumber] = 1,
                SUMX (
                    FILTER ( _t02, [@assetequipment] = EARLIER ( [@assetequipment] ) ),
                    [@modelnumber]
                )
            ),
        "Manufacturer",
            IF (
                [@manufacturer] = 1,
                SUMX (
                    FILTER ( _t02, [@assetequipment] = EARLIER ( [@assetequipment] ) ),
                    [@manufacturer]
                )
            ),
        "Startupdate",
            IF (
                [@startupdate] = 1,
                SUMX (
                    FILTER ( _t02, [@assetequipment] = EARLIER ( [@assetequipment] ) ),
                    [@startupdate]
                )
            )
    )
RETURN
    SUMMARIZE (
        _result,
        [@assetequipment],
        [ModelNumber],
        [Manufacturer],
        [Startupdate]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Jihwan_Kim_0-1697693190721.png

 

 

New Table DAX formula =
VAR _t01 =
    SELECTCOLUMNS (
        Table1,
        "@assetequipment", Table1[Asset Equipment],
        "@modelnumber", IF ( Table1[Model number] <> BLANK (), 1 ),
        "@manufacturer", IF ( Table1[Manufacturer] <> BLANK (), 1 ),
        "@startupdate", IF ( Table1[Start-up date] <> BLANK (), 1 )
    )
VAR _t02 =
    SELECTCOLUMNS (
        Table2,
        "@assetequipment", Table2[Asset Equipment],
        "@modelnumber", IF ( Table2[Model number] <> BLANK (), 1 ),
        "@manufacturer", IF ( Table2[Manufacturer] <> BLANK (), 1 ),
        "@startupdate", IF ( Table2[Start-up date] <> BLANK (), 1 )
    )
VAR _result =
    ADDCOLUMNS (
        _t01,
        "ModelNumber",
            IF (
                [@modelnumber] = 1,
                SUMX (
                    FILTER ( _t02, [@assetequipment] = EARLIER ( [@assetequipment] ) ),
                    [@modelnumber]
                )
            ),
        "Manufacturer",
            IF (
                [@manufacturer] = 1,
                SUMX (
                    FILTER ( _t02, [@assetequipment] = EARLIER ( [@assetequipment] ) ),
                    [@manufacturer]
                )
            ),
        "Startupdate",
            IF (
                [@startupdate] = 1,
                SUMX (
                    FILTER ( _t02, [@assetequipment] = EARLIER ( [@assetequipment] ) ),
                    [@startupdate]
                )
            )
    )
RETURN
    SUMMARIZE (
        _result,
        [@assetequipment],
        [ModelNumber],
        [Manufacturer],
        [Startupdate]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you so much Kim. 🤗

Diana

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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