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
Paulompm
Frequent Visitor

Division with condition

I need a dax formulas that bring the % of each day on a month. The condition is: Same type of product. Not all products together. I usually get this with a simple division:

 

[product type sales of the day]   /  [Sum product type sales of the month]

 

I tried to use this but without success:

 

%ByDay:=DIVIDE(SUM(table[Value];CALCULATE(SUM(table[Value];ALLEXCEPT(table;table[product type])))

 

I use only one table, ie there are no relationships with other tables.

Maybe the problem is because there is more than one year/one month, idk.

 

Expected result

 

Example 1:

 

large.png

 

 

 

 

 

 

 

 

 

 

 

 

Example 2:

 

exemple.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Any help must be apreciated.  Blessings!

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Paulompm,

 

You can try to use below formula:

 

Current of Total= Divide(SUM(Table[Value]),SUMX(All(Table),[Value]),0)

Current of Total(Same Type)=
if(COUNTROWS(Table)<>COUNTROWS(ALL(Table)),
Divide(SUM(Table[Value]),SUMX(FILTER(ALL(Table),Table[Product Type]=max(Table[Product Type])),[Value]),0),1)

Regards,

 

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Man, what you have feels so correct though!?

 

%ByDay:=DIVIDE(SUM(table[Value];CALCULATE(SUM(table[Value];ALLEXCEPT(table;table[product type])))

 

Maybe just split it out to help debugging?

 

Total Value := SUM(table[Value])
Total Value - All In Type := CALCULATE([Total Value], ALLEXCEPT('Table', 'Table'[Product Type]))
% in Type := DIVIDE([Total Value], [Total Value - All In Type])

There is no reason why this should change the result, but just to blow our minds... maybe try:

Total Value - All In Type := CALCULATE([Total Value], ALL('Table'), VALUES('Table'[Product Type]))

Hi @Anonymous,


I have test on sample file and get the result which he wanted:

 

Capture.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
v-shex-msft
Community Support
Community Support

Hi @Paulompm,

 

You can try to use below formula:

 

Current of Total= Divide(SUM(Table[Value]),SUMX(All(Table),[Value]),0)

Current of Total(Same Type)=
if(COUNTROWS(Table)<>COUNTROWS(ALL(Table)),
Divide(SUM(Table[Value]),SUMX(FILTER(ALL(Table),Table[Product Type]=max(Table[Product Type])),[Value]),0),1)

Regards,

 

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help 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.